Move three grob properties from internal to user
[lilypond.git] / elisp / server.el.patch
blobfb3c59f189ae700753bf8dbe0c4a1456e3c3307c
1 From: Jan Nieuwenhuizen <janneke@gnu.org>
2 Subject: Bugfix and feature for server.el
3 To: emacs-devel@gnu.org
4 cc: Han-Wen <hanwen@cs.uu.nl>
5 Date: Sat, 10 Aug 2002 17:46:22 +0200
6 Organization: Jan at Peder
9 Find the following fix attached. We had a problem with our
10 application that uses `emacslient --no-wait' to edit input files.
12 Emacs-21.2 (unlike previous versions), when invoked through
13 `emacsclient --no-wait', wants to revert buffers whenever they have
14 been edited, and does allow any editing, which is annoying. When
15 invoking with --no-wait, we are typically `moving around' and editing
16 the same file all the time; and do not want to revert.
18 When it does revert the buffer, it does not use the column argument of
19 emacsclient; this is now fixed.
21 Greetings,
22 Han-Wen and Jan.
25 Btw: this message was sent to bug-gnu-emacs about three weeks ago, but
26 that list seems to be slightly foobarred? We both have current
27 disclaimers with GNU.
30 ChangeLog:
31 2002-07-21 Jan Nieuwenhuizen <janneke@gnu.org>
33 * server.el (server-process-filter): Cleanup stray if. Add
34 'no-revert to file list entry when emacsclient was invoked with
35 '--no-wait'.
36 (server-visit-files): New function goto-line-column. Accept
37 'no-revert option. Bugfix: also goto column when reverting
38 buffer.
40 --- server.el.~1.78.~ 2001-12-18 17:42:38.000000000 +0100
41 +++ server.el 2002-08-10 17:32:10.000000000 +0200
42 @@ -251,40 +251,43 @@ Prefix arg means just kill any existing
43 (substring request (match-beginning 0) (1- (match-end 0))))
44 (pos 0))
45 (setq request (substring request (match-end 0)))
46 - (if (string-match "\\`-nowait" arg)
47 - (setq nowait t)
48 - (cond
49 - ;; ARG is a line number option.
50 - ((string-match "\\`\\+[0-9]+\\'" arg)
51 + (cond
52 + ((string-match "\\`-nowait" arg)
53 + (setq nowait t))
54 + ;; ARG is a line number option.
55 + ((string-match "\\`\\+[0-9]+\\'" arg)
56 (setq lineno (string-to-int (substring arg 1))))
57 - ;; ARG is line number:column option.
58 - ((string-match "\\`+\\([0-9]+\\):\\([0-9]+\\)\\'" arg)
59 - (setq lineno (string-to-int (match-string 1 arg))
60 - columnno (string-to-int (match-string 2 arg))))
61 - (t
62 - ;; ARG is a file name.
63 - ;; Collapse multiple slashes to single slashes.
64 - (setq arg (command-line-normalize-file-name arg))
65 - ;; Undo the quoting that emacsclient does
66 - ;; for certain special characters.
67 - (while (string-match "&." arg pos)
68 - (setq pos (1+ (match-beginning 0)))
69 - (let ((nextchar (aref arg pos)))
70 - (cond ((= nextchar ?&)
71 - (setq arg (replace-match "&" t t arg)))
72 - ((= nextchar ?-)
73 - (setq arg (replace-match "-" t t arg)))
74 - (t
75 - (setq arg (replace-match " " t t arg))))))
76 - ;; Now decode the file name if necessary.
77 - (if coding-system
78 - (setq arg (decode-coding-string arg coding-system)))
79 - (setq files
80 - (cons (list arg lineno columnno)
81 - files))
82 - (setq lineno 1)
83 - (setq columnno 0))))))
84 - (run-hooks 'pre-command-hook)
85 + ;; ARG is line number:column option.
86 + ((string-match "\\`+\\([0-9]+\\):\\([0-9]+\\)\\'" arg)
87 + (setq lineno (string-to-int (match-string 1 arg))
88 + columnno (string-to-int (match-string 2 arg))))
89 + (t
90 + ;; ARG is a file name.
91 + ;; Collapse multiple slashes to single slashes.
92 + (setq arg (command-line-normalize-file-name arg))
93 + ;; Undo the quoting that emacsclient does
94 + ;; for certain special characters.
95 + (while (string-match "&." arg pos)
96 + (setq pos (1+ (match-beginning 0)))
97 + (let ((nextchar (aref arg pos)))
98 + (cond ((= nextchar ?&)
99 + (setq arg (replace-match "&" t t arg)))
100 + ((= nextchar ?-)
101 + (setq arg (replace-match "-" t t arg)))
102 + (t
103 + (setq arg (replace-match " " t t arg))))))
104 + ;; Now decode the file name if necessary.
105 + (if coding-system
106 + (setq arg (decode-coding-string arg coding-system)))
107 + (setq files
108 + ;; When invoking emacsclient with --no-wait, we are
109 + ;; typically `moving around' and editing the same file;
110 + ;; and do not want to revert. Should make --no-revert
111 + ;; option for emacsclient?
112 + (cons (list arg lineno columnno (if nowait 'no-revert nil))
113 + files))
114 + (setq lineno 1)
115 + (setq columnno 0)))))
116 (server-visit-files files client nowait)
117 (run-hooks 'post-command-hook)
118 ;; CLIENT is now a list (CLIENTNUM BUFFERS...)
119 @@ -309,6 +312,13 @@ Prefix arg means just kill any existing
120 FILES is an alist whose elements are (FILENAME LINENUMBER COLUMNNUMBER).
121 NOWAIT non-nil means this client is not waiting for the results,
122 so don't mark these buffers specially, just visit them normally."
124 + (defun goto-line-column (file-line-col)
125 + (goto-line (nth 1 file-line-col))
126 + (let ((column-number (nth 2 file-line-col)))
127 + (if (> column-number 0)
128 + (move-to-column (1- column-number)))))
130 ;; Bind last-nonmenu-event to force use of keyboard, not mouse, for queries.
131 (let (client-record (last-nonmenu-event t) (obuf (current-buffer)))
132 ;; Restore the current buffer afterward, but not using save-excursion,
133 @@ -322,7 +332,8 @@ so don't mark these buffers specially, j
134 (let* ((filen (car (car files)))
135 (obuf (get-file-buffer filen)))
136 (push filen file-name-history)
137 - (if (and obuf (set-buffer obuf))
138 + (if (and obuf (set-buffer obuf)
139 + (not (memq 'no-revert (car files))))
140 (progn
141 (cond ((file-exists-p filen)
142 (if (or (not (verify-visited-file-modtime obuf))
143 @@ -335,12 +346,9 @@ so don't mark these buffers specially, j
144 ", write buffer to file? "))
145 (write-file filen))))
146 (setq server-existing-buffer t)
147 - (goto-line (nth 1 (car files))))
148 + (goto-line-column (car files)))
149 (set-buffer (find-file-noselect filen))
150 - (goto-line (nth 1 (car files)))
151 - (let ((column-number (nth 2 (car files))))
152 - (when (> column-number 0)
153 - (move-to-column (1- column-number))))
154 + (goto-line-column (car files))
155 (run-hooks 'server-visit-hook)))
156 (if (not nowait)
157 (setq server-buffer-clients
160 Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond - The music typesetter
161 http://www.xs4all.nl/~jantien | http://www.lilypond.org