unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Command line open does not use find-file anymore?
@ 2017-09-18  9:00 Everton J. Carpes
  2017-09-18 15:47 ` Óscar Fuentes
  2017-09-19 11:38 ` Michael Heerdegen
  0 siblings, 2 replies; 6+ messages in thread
From: Everton J. Carpes @ 2017-09-18  9:00 UTC (permalink / raw)
  To: help-gnu-emacs

Until emacs 24 I was able to customize file opening using an "advice"
around find-file. It was working for opening from inside emacs and also
from command line.

I use this to deal with common error reports, which are presented in
"filename:lineno" syntax. The suggestion to do this can be found here:

>
https://stackoverflow.com/questions/3139970/open-a-file-at-line-with-filenameline-syntax

After updating to version 25 (actually 25.2.2) and follow the instructions
to update advice which I found here:

>
https://www.gnu.org/software/emacs/manual/html_node/elisp/Porting-old-advice.html

The around is working when find-file is called from inside emacs, but not
when emacs is called from command line.

  1. Emacs 25 doesn't use find-file anymore when opening from command line?
  2. Which function is called now?
  3. Is this the best way to deal with this kind of customization?
  4. How can I learn more about what emacs does when opened?

I spect this is the proper mailing list to post this question. If not,
really sorry and I appreciate instructions about where and how to post this.

Thanks for your time.


P.S.: Just for reference, the code I'm using (the same posted on SO), after
update it into the new advice syntax is:

(defun find-file--line-number (orig-fun filename &optional wildcards)
  "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)))
      (apply orig-fun (list filename wildcards))
      (when line-number
        ;; goto-line is for interactive use
        (goto-char (point-min))
        (forward-line (1- line-number))))))
(advice-add 'find-file :around #'find-file--line-number)







-- 
Everton J. Carpes


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-09-20  1:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-18  9:00 Command line open does not use find-file anymore? Everton J. Carpes
2017-09-18 15:47 ` Óscar Fuentes
2017-09-18 17:36   ` Everton J. Carpes
2017-09-19 11:38 ` Michael Heerdegen
2017-09-19 16:50   ` Eli Zaretskii
2017-09-20  1:16   ` Everton J. Carpes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).