Mercurial > emacs
comparison lisp/server.el @ 38462:a7043adf8855
(server-visit-files): Handle the case the specified
column number is <= 0.
(command-line-1): Add support for +LINE:COLUMN
command line argument.
(server-process-filter, server-visit-files): Add
support for +LINE:COLUMN style emacsclient calls.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 17 Jul 2001 10:55:28 +0000 |
parents | 253f761ad37b |
children | c9de551dd922 |
comparison
equal
deleted
inserted
replaced
38461:23f63206a867 | 38462:a7043adf8855 |
---|---|
230 (coding-system (and default-enable-multibyte-characters | 230 (coding-system (and default-enable-multibyte-characters |
231 (or file-name-coding-system | 231 (or file-name-coding-system |
232 default-file-name-coding-system))) | 232 default-file-name-coding-system))) |
233 client nowait | 233 client nowait |
234 (files nil) | 234 (files nil) |
235 (lineno 1)) | 235 (lineno 1) |
236 (columnno 0)) | |
236 ;; Remove this line from STRING. | 237 ;; Remove this line from STRING. |
237 (setq string (substring string (match-end 0))) | 238 (setq string (substring string (match-end 0))) |
238 (if (string-match "^Error: " request) | 239 (if (string-match "^Error: " request) |
239 (message "Server error: %s" (substring request (match-end 0))) | 240 (message "Server error: %s" (substring request (match-end 0))) |
240 (if (string-match "^Client: " request) | 241 (if (string-match "^Client: " request) |
247 (substring request (match-beginning 0) (1- (match-end 0)))) | 248 (substring request (match-beginning 0) (1- (match-end 0)))) |
248 (pos 0)) | 249 (pos 0)) |
249 (setq request (substring request (match-end 0))) | 250 (setq request (substring request (match-end 0))) |
250 (if (string-match "\\`-nowait" arg) | 251 (if (string-match "\\`-nowait" arg) |
251 (setq nowait t) | 252 (setq nowait t) |
252 (if (string-match "\\`\\+[0-9]+\\'" arg) | 253 (cond |
253 ;; ARG is a line number option. | 254 ;; ARG is a line number option. |
254 (setq lineno (read (substring arg 1))) | 255 ((string-match "\\`\\+[0-9]+\\'" arg) |
256 (setq lineno (string-to-int (substring arg 1)))) | |
257 ;; ARG is line number:column option. | |
258 ((string-match "\\`+\\([0-9]+\\):\\([0-9]+\\)\\'" arg) | |
259 (setq lineno (string-to-int (match-string 1 arg)) | |
260 columnno (string-to-int (match-string 2 arg)))) | |
261 (t | |
255 ;; ARG is a file name. | 262 ;; ARG is a file name. |
256 ;; Collapse multiple slashes to single slashes. | 263 ;; Collapse multiple slashes to single slashes. |
257 (setq arg (command-line-normalize-file-name arg)) | 264 (setq arg (command-line-normalize-file-name arg)) |
258 ;; Undo the quoting that emacsclient does | 265 ;; Undo the quoting that emacsclient does |
259 ;; for certain special characters. | 266 ;; for certain special characters. |
268 (setq arg (replace-match " " t t arg)))))) | 275 (setq arg (replace-match " " t t arg)))))) |
269 ;; Now decode the file name if necessary. | 276 ;; Now decode the file name if necessary. |
270 (if coding-system | 277 (if coding-system |
271 (setq arg (decode-coding-string arg coding-system))) | 278 (setq arg (decode-coding-string arg coding-system))) |
272 (setq files | 279 (setq files |
273 (cons (list arg lineno) | 280 (cons (list arg lineno columnno) |
274 files)) | 281 files)) |
275 (setq lineno 1))))) | 282 (setq lineno 1) |
283 (setq columnno 0)))))) | |
276 (server-visit-files files client nowait) | 284 (server-visit-files files client nowait) |
277 ;; CLIENT is now a list (CLIENTNUM BUFFERS...) | 285 ;; CLIENT is now a list (CLIENTNUM BUFFERS...) |
278 (if (null (cdr client)) | 286 (if (null (cdr client)) |
279 ;; This client is empty; get rid of it immediately. | 287 ;; This client is empty; get rid of it immediately. |
280 (progn | 288 (progn |
291 ;; Save for later any partial line that remains. | 299 ;; Save for later any partial line that remains. |
292 (setq server-previous-string string)) | 300 (setq server-previous-string string)) |
293 | 301 |
294 (defun server-visit-files (files client &optional nowait) | 302 (defun server-visit-files (files client &optional nowait) |
295 "Finds FILES and returns the list CLIENT with the buffers nconc'd. | 303 "Finds FILES and returns the list CLIENT with the buffers nconc'd. |
296 FILES is an alist whose elements are (FILENAME LINENUMBER). | 304 FILES is an alist whose elements are (FILENAME LINENUMBER COLUMNNUMBER). |
297 NOWAIT non-nil means this client is not waiting for the results, | 305 NOWAIT non-nil means this client is not waiting for the results, |
298 so don't mark these buffers specially, just visit them normally." | 306 so don't mark these buffers specially, just visit them normally." |
299 ;; Bind last-nonmenu-event to force use of keyboard, not mouse, for queries. | 307 ;; Bind last-nonmenu-event to force use of keyboard, not mouse, for queries. |
300 (let (client-record (last-nonmenu-event t) (obuf (current-buffer))) | 308 (let (client-record (last-nonmenu-event t) (obuf (current-buffer))) |
301 ;; Restore the current buffer afterward, but not using save-excursion, | 309 ;; Restore the current buffer afterward, but not using save-excursion, |
323 (write-file filen)))) | 331 (write-file filen)))) |
324 (setq server-existing-buffer t) | 332 (setq server-existing-buffer t) |
325 (goto-line (nth 1 (car files)))) | 333 (goto-line (nth 1 (car files)))) |
326 (set-buffer (find-file-noselect filen)) | 334 (set-buffer (find-file-noselect filen)) |
327 (goto-line (nth 1 (car files))) | 335 (goto-line (nth 1 (car files))) |
336 (let ((column-number (nth 2 (car files)))) | |
337 (when (> column-number 0) | |
338 (move-to-column (1- column)))) | |
328 (run-hooks 'server-visit-hook))) | 339 (run-hooks 'server-visit-hook))) |
329 (if (not nowait) | 340 (if (not nowait) |
330 (setq server-buffer-clients | 341 (setq server-buffer-clients |
331 (cons (car client) server-buffer-clients))) | 342 (cons (car client) server-buffer-clients))) |
332 (setq client-record (cons (current-buffer) client-record)) | 343 (setq client-record (cons (current-buffer) client-record)) |