aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2008-01-16 16:21:08 +0000
committerStefan Monnier2008-01-16 16:21:08 +0000
commit656d4706ab9f836b5e24f7da29e420491a7976de (patch)
tree9f5782dfca8cde8f95817191e868157b5f10d63f
parent7d7d1bb69d0d5d2d1df13947a66be1b17ee120bf (diff)
downloademacs-656d4706ab9f836b5e24f7da29e420491a7976de.tar.gz
emacs-656d4706ab9f836b5e24f7da29e420491a7976de.zip
(server-process-filter): Replace lineno and columnnno
which defaulted to 1&0 with filepos which defaults to nil. (server-goto-line-column): Don't move if filepos is nil. (server-visit-files): Slight restructure to consolidate two calls to server-goto-line-column into just one.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/server.el71
2 files changed, 41 insertions, 37 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d426c72a4b7..4e049abdc67 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
12008-01-16 Stefan Monnier <monnier@iro.umontreal.ca> 12008-01-16 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * server.el (server-process-filter): Replace lineno and columnnno
4 which defaulted to 1&0 with filepos which defaults to nil.
5 (server-goto-line-column): Only receive the filepos.
6 Only move if filepos is non-nil.
7 (server-visit-files): Slight restructure to consolidate two calls to
8 server-goto-line-column into just one.
9
3 * nxml/nxml-mode.el (nxml-mode): Use mode-line-process to indicate 10 * nxml/nxml-mode.el (nxml-mode): Use mode-line-process to indicate
4 the use of degraded mode. 11 the use of degraded mode.
5 (nxml-degrade): Don't change mode-name. 12 (nxml-degrade): Don't change mode-name.
diff --git a/lisp/server.el b/lisp/server.el
index 63245135347..8e14ffa3826 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -805,8 +805,7 @@ The following commands are accepted by the client:
805 (tty-name nil) ;nil, `window-system', or the tty name. 805 (tty-name nil) ;nil, `window-system', or the tty name.
806 tty-type ;string. 806 tty-type ;string.
807 (files nil) 807 (files nil)
808 (lineno 1) 808 (filepos nil)
809 (columnno 0)
810 command-line-args-left 809 command-line-args-left
811 arg) 810 arg)
812 ;; Remove this line from STRING. 811 ;; Remove this line from STRING.
@@ -876,9 +875,9 @@ The following commands are accepted by the client:
876 (string-match "\\+\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)?" 875 (string-match "\\+\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)?"
877 (car command-line-args-left))) 876 (car command-line-args-left)))
878 (setq arg (pop command-line-args-left)) 877 (setq arg (pop command-line-args-left))
879 (setq lineno (string-to-number (match-string 1 arg)) 878 (setq filepos
880 columnno (if (null (match-end 2)) 0 879 (cons (string-to-number (match-string 1 arg))
881 (string-to-number (match-string 2 arg))))) 880 (string-to-number (or (match-string 2 arg) "")))))
882 881
883 ;; -file FILENAME: Load the given file. 882 ;; -file FILENAME: Load the given file.
884 ((and (equal "-file" arg) 883 ((and (equal "-file" arg)
@@ -887,11 +886,10 @@ The following commands are accepted by the client:
887 (if coding-system 886 (if coding-system
888 (setq file (decode-coding-string file coding-system))) 887 (setq file (decode-coding-string file coding-system)))
889 (setq file (command-line-normalize-file-name file)) 888 (setq file (command-line-normalize-file-name file))
890 (push (list file lineno columnno) files) 889 (push (cons file filepos) files)
891 (server-log (format "New file: %s (%d:%d)" 890 (server-log (format "New file: %s %s"
892 file lineno columnno) proc)) 891 file (or filepos "")) proc))
893 (setq lineno 1 892 (setq filepos nil))
894 columnno 0))
895 893
896 ;; -eval EXPR: Evaluate a Lisp expression. 894 ;; -eval EXPR: Evaluate a Lisp expression.
897 ((and (equal "-eval" arg) 895 ((and (equal "-eval" arg)
@@ -901,8 +899,7 @@ The following commands are accepted by the client:
901 (setq expr (decode-coding-string expr coding-system))) 899 (setq expr (decode-coding-string expr coding-system)))
902 (push (lambda () (server-eval-and-print expr proc)) 900 (push (lambda () (server-eval-and-print expr proc))
903 commands) 901 commands)
904 (setq lineno 1 902 (setq filepos nil)))
905 columnno 0)))
906 903
907 ;; -env NAME=VALUE: An environment variable. 904 ;; -env NAME=VALUE: An environment variable.
908 ((and (equal "-env" arg) command-line-args-left) 905 ((and (equal "-env" arg) command-line-args-left)
@@ -991,18 +988,19 @@ The following commands are accepted by the client:
991 (server-log (error-message-string err) proc) 988 (server-log (error-message-string err) proc)
992 (delete-process proc))) 989 (delete-process proc)))
993 990
994(defun server-goto-line-column (file-line-col) 991(defun server-goto-line-column (line-col)
995 "Move point to the position indicated in FILE-LINE-COL. 992 "Move point to the position indicated in LINE-COL.
996FILE-LINE-COL should be a three-element list as described in 993LINE-COL should be a pair (LINE . COL)."
997`server-visit-files'." 994 (when line-col
998 (goto-line (nth 1 file-line-col)) 995 (goto-line (car line-col))
999 (let ((column-number (nth 2 file-line-col))) 996 (let ((column-number (cdr line-col)))
1000 (when (> column-number 0) 997 (when (> column-number 0)
1001 (move-to-column (1- column-number))))) 998 (move-to-column (1- column-number))))))
1002 999
1003(defun server-visit-files (files proc &optional nowait) 1000(defun server-visit-files (files proc &optional nowait)
1004 "Find FILES and return a list of buffers created. 1001 "Find FILES and return a list of buffers created.
1005FILES is an alist whose elements are (FILENAME LINENUMBER COLUMNNUMBER). 1002FILES is an alist whose elements are (FILENAME . FILEPOS)
1003where FILEPOS can be nil or a pair (LINENUMBER . COLUMNNUMBER).
1006PROC is the client that requested this operation. 1004PROC is the client that requested this operation.
1007NOWAIT non-nil means this client is not waiting for the results, 1005NOWAIT non-nil means this client is not waiting for the results,
1008so don't mark these buffers specially, just visit them normally." 1006so don't mark these buffers specially, just visit them normally."
@@ -1021,22 +1019,21 @@ so don't mark these buffers specially, just visit them normally."
1021 (filen (car file)) 1019 (filen (car file))
1022 (obuf (get-file-buffer filen))) 1020 (obuf (get-file-buffer filen)))
1023 (add-to-history 'file-name-history filen) 1021 (add-to-history 'file-name-history filen)
1024 (if (and obuf (set-buffer obuf)) 1022 (if (null obuf)
1025 (progn 1023 (set-buffer (find-file-noselect filen))
1026 (cond ((file-exists-p filen) 1024 (set-buffer obuf)
1027 (when (not (verify-visited-file-modtime obuf)) 1025 (cond ((file-exists-p filen)
1028 (revert-buffer t nil))) 1026 (when (not (verify-visited-file-modtime obuf))
1029 (t 1027 (revert-buffer t nil)))
1030 (when (y-or-n-p 1028 (t
1031 (concat "File no longer exists: " filen 1029 (when (y-or-n-p
1032 ", write buffer to file? ")) 1030 (concat "File no longer exists: " filen
1033 (write-file filen)))) 1031 ", write buffer to file? "))
1034 (unless server-buffer-clients 1032 (write-file filen))))
1035 (setq server-existing-buffer t)) 1033 (unless server-buffer-clients
1036 (server-goto-line-column file)) 1034 (setq server-existing-buffer t)))
1037 (set-buffer (find-file-noselect filen)) 1035 (server-goto-line-column (cdr file))
1038 (server-goto-line-column file) 1036 (run-hooks 'server-visit-hook))
1039 (run-hooks 'server-visit-hook)))
1040 (unless nowait 1037 (unless nowait
1041 ;; When the buffer is killed, inform the clients. 1038 ;; When the buffer is killed, inform the clients.
1042 (add-hook 'kill-buffer-hook 'server-kill-buffer nil t) 1039 (add-hook 'kill-buffer-hook 'server-kill-buffer nil t)