;ELC ;;; Compiled by cyd@localhost on Mon Apr 23 22:21:08 2007 ;;; from file /home/cyd/emacs/lisp/server.el ;;; in Emacs version 22.0.99 ;;; with all optimizations. ;;; This file uses dynamic docstrings, first added in Emacs 19.29. (if (and (boundp 'emacs-version) (< (aref emacs-version (1- (length emacs-version))) ?A) (or (and (boundp 'epoch::version) epoch::version) (string-lessp emacs-version "19.29"))) (error "`server.el' was compiled for Emacs 19.29 or later")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (custom-declare-group 'server nil "Emacs running as a server process." :group 'external) #@55 If non-nil, use TCP sockets instead of local sockets. (custom-declare-variable 'server-use-tcp 'nil '(#$ . 648) :set #[(sym val) "\303\304\305\"\204\306 \204\307\310!\210\203\311\306!\210\312\n\"\207" [val load-in-progress sym featurep make-network-process (:family local) t message "Local sockets unsupported, using TCP sockets" random set-default] 3] :group 'server :type 'boolean :version "22.1") #@140 The name or IP address to use as host address of the server process. If set, the server accepts remote connections; otherwise it is local. (custom-declare-variable 'server-host 'nil '(#$ . 1064) :group 'server :type '(choice (string :tag "Name or IP address") (const :tag "Local" nil)) :version "22.1") (put 'server-host 'risky-local-variable t) #@44 Directory for server authentication files. (custom-declare-variable 'server-auth-dir '"~/.emacs.d/server/" '(#$ . 1416) :group 'server :type 'directory :version "22.1") (put 'server-auth-dir 'risky-local-variable t) #@53 If non-nil, raise frame when switching to a buffer. (custom-declare-variable 'server-raise-frame 't '(#$ . 1638) :group 'server :type 'boolean :version "22.1") #@53 Hook run when visiting a file for the Emacs server. (custom-declare-variable 'server-visit-hook 'nil '(#$ . 1804) :group 'server :type 'hook) #@59 Hook run when switching to a buffer for the Emacs server. (custom-declare-variable 'server-switch-hook 'nil '(#$ . 1952) :group 'server :type 'hook) #@59 Hook run when done editing a buffer for the Emacs server. (custom-declare-variable 'server-done-hook 'nil '(#$ . 2107) :group 'server :type 'hook) #@29 The current server process. (defvar server-process nil (#$ . 2260)) #@225 List of current server clients. Each element is (CLIENTID BUFFERS...) where CLIENTID is a string that can be given to the server process to identify a client. When a buffer is marked as "done", it is removed from this list. (defvar server-clients nil (#$ . 2335)) #@70 List of client ids for clients requesting editing of current buffer. (defvar server-buffer-clients nil (#$ . 2605)) (byte-code "\300\301!\210\302\301\303\304#\207" [make-variable-buffer-local server-buffer-clients put permanent-local t] 4) #@410 Specification of the window to use for selecting Emacs server buffers. If nil, use the selected window. If it is a function, it should take one argument (a buffer) and display and select it. A common value is `pop-to-buffer'. If it is a window, use that. If it is a frame, use the frame's selected window. It is not meaningful to set this to a specific frame or window with Custom. Only programs can do so. (custom-declare-variable 'server-window 'nil '(#$ . 2852) :group 'server :version "22.1" :type '(choice (const :tag "Use selected window" :match (lambda (widget value) (not (functionp value))) nil) (function-item :tag "Use pop-to-buffer" pop-to-buffer) (function :tag "Other function"))) #@134 Regexp matching names of temporary files. These are deleted and reused after each edit by the programs that invoke the Emacs server. (custom-declare-variable 'server-temp-file-regexp '"^/tmp/Re\\|/draft$" '(#$ . 3556) :group 'server :type 'regexp) #@353 Whether to kill buffers when done with them. If non-nil, kill a buffer unless it already existed before editing it with Emacs server. If nil, kill only buffers as specified by `server-temp-file-regexp'. Please note that only buffers are killed that still have a client, i.e. buffers visited which "emacsclient --no-wait" are never killed in this way. (custom-declare-variable 'server-kill-new-buffers 't '(#$ . 3811) :group 'server :type 'boolean :version "21.1") (byte-code "\301\236\204\n\302B\301\207" [minor-mode-alist server-buffer-clients (server-buffer-clients " Server")] 2) #@178 Non-nil means the buffer existed before the server was asked to visit it. This means that the server should not kill the buffer when you say you are done with it in the server. (defvar server-existing-buffer nil (#$ . 4406)) (byte-code "\301\302!\210\303B\304\303!\204\305\303\306\"\210\307B\304\307!\204&\305\307\310\311\312 \"\"\210\301\207" [current-load-list make-variable-buffer-local server-existing-buffer server-name default-boundp set-default "server" server-socket-dir format "/tmp/emacs%d" user-uid] 5) #@71 If a *server* buffer exists, write STRING to it for logging purposes. (defalias 'server-log #[(string &optional client) "\302\303!\205&r\303q\210db\210\304 \203\305\306\"\202\307 \261\210n\206%\310 )\207" [client string get-buffer "*server*" current-time-string format " %s:" " " newline] 4 (#$ . 4933)]) (defalias 'server-sentinel #[(proc msg) " \236\211\203B\306\n \"\nA\307\211\203A\f@r q\210\306 \"\211\2049\2030\2035\310 \2039\311p!\210)\fA\211\204*)\312!\313=\203V\314!\203V\315\307\"\210\316\317\320\312!\"\"\207" [proc server-clients client buf #1=#:--cl-dolist-temp-- server-buffer-clients delq nil server-temp-file-p kill-buffer process-status open process-query-on-exit-flag set-process-query-on-exit-flag server-log format "Status changed to %s" server-kill-new-buffers server-existing-buffer] 6]) (defalias 'server-select-display #[(display) "\304\305 \300\"\232?\205N\306 \307\211\203+\n@\304 \300\"\232\203$\310 !\210\nA\211\204*\304\305 \300\"\232?\205N\311\312!\313\314 B\315B\"\310 !\210\316\317 \"*\207" [display frame #1=#:--cl-dolist-temp-- buffer frame-parameter selected-frame frame-list nil select-frame generate-new-buffer " *server-dummy*" make-frame-on-display server-dummmy-buffer ((visibility)) set-window-buffer selected-window] 4]) (defalias 'server-unselect-display #[(frame) "\301!\302\301!\303\"=\203!\304\301!!\305\306\"=\203!\307!\210\202'\310\311\312#\210\313\305\306\"!\210\310\306\314#\207" [frame frame-first-window next-window nomini window-buffer frame-parameter server-dummy-buffer delete-frame set-frame-parameter visibility t kill-buffer nil] 4]) (defalias 'server-unquote-arg #[(arg) "\301\302\303\304\211%\207" [arg replace-regexp-in-string "&." #[(s) "\301H\302=\203\n\303\207\301H\304=\203\305\207\301H\306=\203\307\207\310\207" [s 1 38 "&" 45 "-" 110 "\n" " "] 2] t] 6]) #@207 Make sure DIR is a directory with no race-condition issues. Creates the directory if necessary and makes sure: - there's no symlink involved - it's owned by us - it's not readable/writable by anybody else. (defalias 'server-ensure-safe-dir #[(dir) "\304!\305!\211\204\306 \307\216\310\311!\210\312\313\"\210*\305! @\313=\205M\314 8\247\2036\314 8\315 \232\202<\314 8\315 =\205M \316=\206M\317\320\321!\322\"!?\205U\323\324\")\207" [dir attrs #1=#:--cl-letf-save-- system-type directory-file-name file-attributes default-file-modes ((byte-code "\302 !\210 \210)\302\207" [#1# #2=#:--cl-store-- set-default-file-modes] 2)) set-default-file-modes 448 make-directory t 2 user-uid windows-nt zerop logand file-modes 63 error "The directory %s is unsafe"] 5 (#$ . 6835)]) #@419 Allow this Emacs process to be a server for client processes. This starts a server communications subprocess through which client "editors" can send your editing commands to this Emacs job. To use the server, set up the program `emacsclient' in the Emacs distribution as your standard "editor". Optional argument LEAVE-DEAD (interactively, a prefix arg) means just kill any existing server communications subprocess. (defalias 'server-start #[(&optional leave-dead) "\203 \306\307\310\217\210 \203 @A@\311\n!\210)\202 ?\205\371\f\203' \202)?@\312A@\"B\313@!\210\306\314\315\217\210\203G\316\317\320!!\210\321 C\322\216\323\324!\210\325\326\327A\330\331\332\331\333\334\335\336\337\340\f\203v\341\306\342\331\343D\206o\344\345\346\257\202\341\344\342B\345\347\257&\211\204\212\350\351!\210\f\205\370\352E\306FE\353W\203\257F\354\355!\356\\C\244FET\211E\202\226F\260*G\357\360G#\210B\361\362\363!!HI\364\216rHq\210\365\306!\210\366J\367\370\371\"!\372\373\374 !\375G\261)rHq\210~\210\376edI\306\352%\210-,\207" [server-process server-clients buffer leave-dead server-use-tcp server-auth-dir nil (delete-process server-process) ((error)) server-buffer-done expand-file-name server-ensure-safe-dir (delete-file server-file) ((error)) server-log message "Restarting server" default-file-modes ((byte-code "\302 !\210 \210)\302\207" [#1=#:--cl-letf-save-- #2=#:--cl-store-- set-default-file-modes] 2)) set-default-file-modes 448 apply make-network-process :name :server t :noquery :sentinel server-sentinel :filter server-process-filter :coding raw-text :family :service :host local :plist (:authenticated nil) (:authenticated t) error "Could not start server process" 0 64 random 94 33 process-put :auth-key get-buffer-create generate-new-buffer-name " *temp file*" ((byte-code "\301!\203\n\302!\210\301\207" [#3=#:temp-buffer buffer-name kill-buffer] 2)) set-buffer-multibyte no-conversion format-network-address process-contact :local " " int-to-string emacs-pid "\n" write-region server-socket-dir server-dir server-name server-file #1# server-host i auth auth-key #3# #4=#:temp-file buffer-file-coding-system] 23 (#$ . 7628) "P"]) #@254 Non-nil if Server mode is enabled. See the command `server-mode' for a description of this minor-mode. Setting this variable directly does not take effect; either customize it (see the info node `Easy Customization') or call the function `server-mode'. (custom-declare-variable 'server-mode 'nil '(#$ . 9827) :set 'custom-set-minor-mode :initialize 'custom-initialize-default :group 'server :type 'boolean :version "22.1") #@217 Toggle Server mode. With ARG, turn Server mode on if ARG is positive, off otherwise. Server mode runs a process that accepts commands from the `emacsclient' program. See `server-start' and Info node `Emacs server'. (defalias 'server-mode #[(&optional arg) "\302=\203 ?\202%\203\303!\304V\202% \204\305\202%\306\307\301\"\210\310\311 ?!\210\312\313 \2035\314\2026\315\"\210\316 \203N\317\301!\210\306\320 \203K\321\202L\322\"\210\323 \210 \207" [arg server-mode toggle prefix-numeric-value 0 t message "Toggling %s off; better pass an explicit argument." nil server-start run-hooks server-mode-hook server-mode-on-hook server-mode-off-hook called-interactively-p customize-mark-as-set "Server mode %sabled" "en" "dis" force-mode-line-update] 3 (#$ . 10257) (list (or current-prefix-arg 'toggle))]) (byte-code "\300\301\302\303\304!\205 \304J#\207" [add-minor-mode server-mode nil boundp server-mode-map] 5) #@128 Process a request from the server to edit some files. PROC is the server process. Format of STRING is "PATH PATH PATH... \n". (defalias 'server-process-filter #[(proc string) "\300\301\215\207" [--cl-block-server-process-filter-- (byte-code "\306\307\"\204A\310\311 \"\203.\312\313 \"\306\314\"\232\203. \315\225\316O\317\307\320#\210\321\322\"\210\202A\321\323\"\210\324\323\"\210\325!\210\326\327\316\"\210\321 \"\210\306\330\"\211\203Y\n P\317\330\316#\210)\331 \315V\203\202\317\330 #\210\332\315\316\333\334!\211L\210\335\336\337\340\341 D\342FE)#\210\343 \210\316\344\345\217\210\310\346 \"\203> \315\211\224O\f\205\235 \206\235@\316\211\211\211\313\316\315ABCDEFGHI \315\225\316O\316BG\310\347I\"\203\270I\315\224\315\225SOJI\315\225\316OIJ\350\232\203\350\320F\202\264J\351\232\203\365\320E\202\264J\352\232\203\310\353I\"\203\354\312\313I\"!KI\315\225\316OI\355\356\357\217\210)\202\264\310\360J\"\2032\361J\313\316O!C\202\264\310\362J\"\203O\361\312\313J\"!C\361\312\363J\"!A\202\264\354J!JH\203b\364JH\"JE\203\233\316L\365\366\367\217\211M\203\227\370\371!N\372\216rNq\210pOL\203\214\373\374!\210\375M!\210\316\376\377\217\210,*\202\256\201RJ!\211JCAEDBD\313C\315A)\202\301D\203\330\201S\201T!\210\201UDGF#\210\201S\201V!\210GA\204\354\325!\210\321\201W\"\210\202)F\204\370GPBPQ\204)\201X \204)\201YGA@!\210\201S\201Z!\210F\204)\201[\201\\\201]\201^!\"\210\201_B!\2039\201`B!\210. \202\207 G\315V\205J\317\330 #\207" [proc string prev #1=#:--cl-proc-- default-enable-multibyte-characters file-name-coding-system process-get :authenticated string-match "-auth \\(.*?\\)\n" match-string 1 :auth-key 0 nil process-put t server-log "Authentication successful" "Authentication failed" process-send-string delete-process throw --cl-block-server-process-filter-- :previous-string recursion-depth run-with-timer make-symbol "--proc--" lambda (&rest --cl-rest--) apply #[(#2=#:G78200) "\301J\302\"\207" [#2# server-process-filter ""] 3] quote --cl-rest-- top-level (byte-code "\300\301\302 \"\207" [mapc #[(buffer) "rq\210\302\301!\205 \205\303 )\207" [buffer isearch-mode boundp isearch-cancel] 2] buffer-list] 3) ((quit (message nil))) "\n" "[^ ]* " "-nowait" "-eval" "-display" "\\([^ ]*\\) " server-unquote-arg err (byte-code "\302!\302\207" [display tmp-frame server-select-display] 2) ((error (byte-code "\303 A@\"\210\304\303\207" [proc err request process-send-string ""] 3))) "\\`\\+[0-9]+\\'" string-to-number "\\`+\\([0-9]+\\):\\([0-9]+\\)\\'" 2 decode-coding-string errobj (byte-code "\301\302!@!\207" [arg eval read-from-string] 3) ((error (byte-code "\302 \207" [errorp errobj t] 1))) generate-new-buffer " *temp*" ((byte-code "\301!\203\n\302!\210\301\207" [#3=#:temp-buffer buffer-name kill-buffer] 2)) princ "error: " pp (byte-code "\301ed#\207" [proc process-send-region] 4) ((error)) default-file-name-coding-system columnno tmp-frame lineno files eval nowait client coding-system request arg display errorp v #3# standard-output server-clients isearch-mode command-line-normalize-file-name run-hooks pre-command-hook server-visit-files post-command-hook "Close empty client" minibufferp server-switch-buffer server-switch-hook message "%s" substitute-command-keys "When done with a buffer, type \\[server-edit]" frame-live-p server-unselect-display] 10)] 2 (#$ . 11190)]) (defalias 'server-goto-line-column #[(file-line-col) "\302A@!\210\3038\211\304V\205\305 S!)\207" [file-line-col column-number goto-line 2 0 move-to-column] 3]) #@268 Find FILES and return the list CLIENT with the buffers nconc'd. FILES is an alist whose elements are (FILENAME LINENUMBER COLUMNNUMBER). NOWAIT non-nil means this client is not waiting for the results, so don't mark these buffers specially, just visit them normally. (defalias 'server-visit-files #[(files client &optional nowait) "\306\307r\n\307\211\203\220\f@ \206 @\310!\311\312\"\210\203bq\203b\313!\203I\314!\204X\315\306\307\"\210\202X\316\317\320Q!\203X\321!\210\306\322 !\210\202p\323!q\210\322 !\210\324\325!\210+\204\205\326\327\330\307\306$\210@BpB\fA\211\204 +\244*\207" [client-record last-nonmenu-event files file #1=#:--cl-dolist-temp-- server-raise-frame t nil get-file-buffer add-to-history file-name-history file-exists-p verify-visited-file-modtime revert-buffer y-or-n-p "File no longer exists: " ", write buffer to file? " write-file server-goto-line-column find-file-noselect run-hooks server-visit-hook add-hook kill-buffer-hook server-kill-buffer minibuffer-auto-raise filen obuf server-existing-buffer nowait client server-buffer-clients] 6 (#$ . 14820)]) #@362 Mark BUFFER as "done" for its client(s). This buries the buffer, then returns a list of the form (NEXT-BUFFER KILLED). NEXT-BUFFER is another server buffer, as a suggestion for what to select next, or nil. KILLED is t if we killed BUFFER (typically, because it was visiting a temp file). FOR-KILLING if non-nil indicates that we are called from `kill-buffer'. (defalias 'server-buffer-done #[(buffer &optional for-killing) "\306\211 \203a @ \204 \f>A@\307 \f\"\210\f\211\203C\310@!\203:\311@!\204:\307@\f\"\210A\211\204#)\fA\204Y\312\f@!\210\313\314\f@\"\210\307\f\") A\211\204\n\310 !\203\301\311 !\203\301\315r q\210\306\316\317!\210)\311 !\204\207\315\202\300\204\300\n\204\251\203\251r q\210)\204\251\315\320 !\210\321 !\210\n\204\300\322 !\203\274\321 !\210\315\202\300\320 !\210) \n+D\207" [server-clients old-clients killed next-buffer client buffer nil delq bufferp buffer-name delete-process server-log "Close" t run-hooks server-done-hook bury-buffer kill-buffer server-temp-file-p tail server-kill-buffer-running server-buffer-clients for-killing server-kill-new-buffers server-existing-buffer] 4 (#$ . 15968)]) #@258 Return non-nil if BUFFER contains a file considered temporary. These are files whose names suggest they are repeatedly reused to pass information to another program. The variable `server-temp-file-regexp' controls which filenames are considered temporary. (defalias 'server-temp-file-p #[(&optional buffer) "\302!\205\f\303 \302!\"\207" [buffer server-temp-file-regexp buffer-file-name string-match] 4 (#$ . 17153)]) #@378 Offer to save current buffer, mark it as "done" for clients. This kills or buries the buffer, then returns a list of the form (NEXT-BUFFER KILLED). NEXT-BUFFER is another server buffer, as a suggestion for what to select next, or nil. KILLED is t if we killed BUFFER, which happens if it was created specifically for the clients and did not exist before their request for it. (defalias 'server-done #[nil "\205,\304 \203\305\211\306 \210*\202)\307 \203) \203)\310\311 \312Q!\203)\306 \210\313p!\207" [server-buffer-clients buffer-backed-up version-control buffer-file-name server-temp-file-p nil save-buffer buffer-modified-p y-or-n-p "Save file " "? " server-buffer-done] 4 (#$ . 17581)]) (defalias 'server-kill-buffer-query-function #[nil "?\206 \301\302\303\304p!\"!\207" [server-buffer-clients yes-or-no-p format "Buffer `%s' still has clients; kill it? " buffer-name] 5]) (add-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function) (defalias 'server-kill-emacs-query-function #[nil "\303 \203\304\305\306\305\307 @A\"\">\203\304 A\211\204\n?\206'\310\311!*\207" [server-clients tail live-client nil t mapcar stringp buffer-name yes-or-no-p "Server buffers still have clients; exit anyway? "] 7]) (add-hook 'kill-emacs-query-functions 'server-kill-emacs-query-function) #@72 Non-nil while `server-kill-buffer' or `server-buffer-done' is running. (defvar server-kill-buffer-running nil (#$ . 18901)) (defalias 'server-kill-buffer #[nil "\206 \205\303\n\205\304p\303\")\207" [server-kill-buffer-running server-buffer-clients server-process t server-buffer-done] 3]) #@773 Switch to next server editing buffer; say "Done" for current buffer. If a server buffer is current, it is marked "done" and optionally saved. The buffer is also killed if it did not exist before the clients asked for it. When all of a client's buffers are marked as "done", the client is notified. Temporary files such as MH files are always saved and backed up, no questions asked. (The variable `make-backup-files', if nil, still inhibits a backup; you can set it locally in a particular buffer to prevent a backup for it.) The variable `server-temp-file-regexp' controls which filenames are considered temporary. If invoked with a prefix argument, or if there is no server process running, starts server process and that is all. Invoked by \[server-edit]. (defalias 'server-edit #[(&optional arg) "\204 \203\303 !\304>\203\305\306!\207\n\203\307\310\311 \"\207\312\313!\207" [arg server-process server-clients process-status (signal exit) server-mode 1 apply server-switch-buffer server-done message "No server editing buffers exist"] 3 (#$ . 19205) "P"]) #@126 Switch to another buffer, preferably one that has a client. Arg NEXT-BUFFER is a suggestion; if it is a live buffer, use it. (defalias 'server-switch-buffer #[(&optional next-buffer killed-one) "\204% \203\306 @A@\n\"\207\n\206\307\310 !?\205$\311\312 !\210\313\314!\207\315!\2045\316\306\317!\"\210\202\247\320 !\203B !\210\202\247\321\322\"\211\203Y \204Y\323\f!\210q\210\202\246\324 !\203l\325 !\203l\323 !\210\202\201\326 !\203\201\327 !\204{\330 \323\331 !!\210\332\310 !\203\220\323\333\334\335\322#!\210\307\310 !\203\241\323\336\337\335\340\310 $!\210\334\341\342\217\210) \205\261\343\344\310 !!\207" [next-buffer server-clients killed-one server-window win server-raise-frame server-switch-buffer window-dedicated-p selected-window switch-to-buffer other-buffer message "No server buffers remain to edit" buffer-name apply server-buffer-done functionp get-buffer-window 0 select-window windowp window-live-p framep frame-live-p make-frame frame-selected-window window-minibuffer-p next-window nil nomini get-window-with-predicate #[(w) "\301!?\205\302\303!\304\"\302\305 \304\"\232\207" [w window-dedicated-p frame-parameter window-frame display selected-frame] 4] visible (switch-to-buffer next-buffer) ((error (pop-to-buffer next-buffer))) select-frame-set-input-focus window-frame] 7 (#$ . 20293)]) (define-key ctl-x-map "#" 'server-edit) (defalias 'server-unload-hook #[nil "\300\301!\210\302\303\304\"\210\302\305\306\"\210\302\307\310\"\207" [server-mode -1 remove-hook kill-buffer-query-functions server-kill-buffer-query-function kill-emacs-query-functions server-kill-emacs-query-function kill-buffer-hook server-kill-buffer] 3]) (byte-code "\300\301\302\"\210\300\303\211\"\210\304\305!\207" [add-hook kill-emacs-hook #[nil "\300\301!\207" [server-mode -1] 2] server-unload-hook provide server] 3)