emacs-bug-tracker
[Top][All Lists]
Advanced

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

[debbugs-tracker] bug#21194: closed (2015-06-01; add support for ffap vi


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#21194: closed (2015-06-01; add support for ffap via kpsewhich)
Date: Sun, 09 Aug 2015 16:50:03 +0000

Your message dated Sun, 09 Aug 2015 18:49:03 +0200
with message-id <address@hidden>
and subject line Re: bug#21194: 2015-06-01; add support for ffap via kpsewhich
has caused the debbugs.gnu.org bug report #21194,
regarding 2015-06-01; add support for ffap via kpsewhich
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
21194: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21194
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 2015-06-01; add support for ffap via kpsewhich Date: Wed, 05 Aug 2015 19:34:56 +0200 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)
Hi all,

I'm using the following customizations, which I thought I'd share with
you. As the subject says it, it uses kpsewhich for guessing a filename
at point. It allows to use M-x ffap with point on "geometry" to find
geometry.sty, or with point on "memoir" to find memoir.cls.

It is very quick because it calls kpsewhich only once.

I'm not making this into an actual patch because while it works
fine on my system, it's not ready for inclusion yet. I'm open to
your ideas to make it better and eventually include it.

;; a first step is :
;; don't allow braces as possible characters in a filename (otherwise
;; \input{foo} is seen as a possible filename, instead of just foo)
;; (this is because of a recent change in emacs, see commit
;; ba6c32b6decaa2a72a3d5f854efd513e8e82c118 for detail)

(push '(latex-mode "--:\\\\$+<>@-Z_[:alpha:]~*?" "<@" "@>;.,!:")
      ffap-string-at-point-mode-alist)

;; second step is to extend rules for finding file at point, and use kpsewhich

(defun yf/ffap-latex-mode (name)
  "ffap function in latex buffers"
  (if (file-exists-p name)
      name
    (let ((curbuf (current-buffer)))
      (with-temp-buffer 
        (let ((suffixes '(".sty" ".cls" ".ltx" ".tex" "" ".ldf"))
              (prefixes '("" "beamertheme"
                          "beamercolortheme"
                          "beamerfonttheme"
                          "beamerinnertheme"
                          "beameroutertheme"))
              args)
          (setq args (apply #'append (mapcar
                                      (lambda (suffix)
                                        (mapcar
                                         (lambda (prefix)
                                           (concat prefix name suffix))
                                         prefixes))
                                      suffixes)))
          (let ((process-environment (buffer-local-value 'process-environment 
curbuf))
                (exec-path (buffer-local-value 'exec-path curbuf)))
            (apply #'call-process "kpsewhich"  nil  t  nil args))
          (when (< (point-min) (point-max))
            (buffer-substring (goto-char (point-min)) (point-at-eol))))))))

;; use the above
(advice-add 'ffap-latex-mode :override 'yf/ffap-latex-mode)

Comments welcome!

Nicolas.



--- End Message ---
--- Begin Message --- Subject: Re: bug#21194: 2015-06-01; add support for ffap via kpsewhich Date: Sun, 09 Aug 2015 18:49:03 +0200 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)
Hello Mosè

Mosè Giordano <address@hidden> writes:
> This is smarter than your function in the sense that it looks at
> current macro to determine the extension (didn't test it, but I think
> your implementation would open "article.sty" instead of the more
> sensible "article.cls" with point on "article").

Indeed, there are a few ways to confuse my code, but it doesn't bite me
often (I never use article class anyway :p). I've fixed this nonetheless.

I pushed the result to emacs master, so it should make its way to emacs
25.1.

Thanks for your comments.

-- 
Nico.


--- End Message ---

reply via email to

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