emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] add emacsclient support to open with file:linum syntax


From: Toon Claes
Subject: Re: [PATCH] add emacsclient support to open with file:linum syntax
Date: Thu, 9 Feb 2017 10:58:01 +0100

On Thu, Mar 31, 2016 at 6:31 AM, Stefan Monnier <address@hidden> wrote:
> FWIW, I think we should try and arrange it so that the way emacsclient and
> server.el work together makes it possible to add such a new FILE:LINE
> syntax via an ELPA package (even if it might require an advice).
>
>
> Stefan

I am a bit sad this patch didn’t get applied, but I understand.

But I found this advice on SO: http://stackoverflow.com/a/3141456/89376

#+BEGIN_SRC emacs-lisp
;; Open files and goto lines like we see from g++ etc. i.e. file:line
(defadvice find-file (around find-file-line-number
                             (filename &optional wildcards)
                             activate)
  "Turn files like file.cpp:14 into file.cpp and going to the 14-th line."
  (save-match-data
    (let* ((matched (string-match "^\\(.*\\):\\([0-9]+\\):?$" filename))
           (line-number (and matched
                             (match-string 2 filename)
                             (string-to-number (match-string 2 filename))))
           (filename (if matched (match-string 1 filename) filename)))
      ad-do-it
      (when line-number
        ;; goto-line is for interactive use
        (goto-char (point-min))
        (forward-line (1- line-number))))))
#+END_SRC

Unfortunately it does not work with emacsclient.
So I could use some pointers on how to make it work with emacsclient.
Would it be possible to achieve this with an advice, since the original
patch was written in c.

Regards,
Toon


reply via email to

[Prev in Thread] Current Thread [Next in Thread]