all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Everton J. Carpes" <everton.carpes@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Command line open does not use find-file anymore?
Date: Mon, 18 Sep 2017 06:00:16 -0300	[thread overview]
Message-ID: <CAL2=v65uCXhTfLCZsabJu5xce7_03gwOEcZVfDVOr00JkYPgqw@mail.gmail.com> (raw)

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


             reply	other threads:[~2017-09-18  9:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-18  9:00 Everton J. Carpes [this message]
2017-09-18 15:47 ` Command line open does not use find-file anymore? Ó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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAL2=v65uCXhTfLCZsabJu5xce7_03gwOEcZVfDVOr00JkYPgqw@mail.gmail.com' \
    --to=everton.carpes@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.