auctex
[Top][All Lists]
Advanced

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

Re: [AUCTeX] Jump to begin of footnote


From: Tassilo Horn
Subject: Re: [AUCTeX] Jump to begin of footnote
Date: Sat, 03 May 2014 11:27:19 +0200
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4.50 (gnu/linux)

LaurentAUCTEX <address@hidden> writes:

Hi Laurent,

>    I try to use these lambdas mais it doesn't work in my emacs :
>
> I did :
>
> (global-set-key (kbd "C-c b")
>                 (lambda ()
>                   (interactive)
>                   (goto-char (TeX-find-macro-start))
>                   (search-forward "{" (TeX-find-macro-end) t)
>                   ))
>
> (global-set-key (kbd "C-c e") (lambda () (interactive)
>  (goto-char (TeX-find-macro-end))))
>
> Then with C-c b I have the message error :
>
> Wrong type argument: integer-or-marker-p, nil

TeX-find-macro-{start,end} both return nil if point is not on a macro or
in one of its arguments.  E.g., in

     This is some \textbf{sample|1| text} bla|2| bla.

it'll work at position |1| but not at |2|.

So maybe you want to have your lambda cater with that situation:

--8<---------------cut here---------------start------------->8---
(lambda ()
  (interactive)
  (let ((pos (TeX-find-macro-start)))
    (when pos
      (goto-char pos)
      (search-forward "{" (TeX-find-macro-end) t))))
--8<---------------cut here---------------end--------------->8---

And you don't want to bind these TeX lambdas to global keys.  Use
something like:

--8<---------------cut here---------------start------------->8---
(add-hook 'TeX-mode-hook
          (lambda ()
            (local-set-key (kbd "C-c a")
                           (lambda ()
                             (interactive)
                             (let ((pos (TeX-find-macro-start)))
                               (when pos
                                 (goto-char pos)
                                 (search-forward "{"
                                 (TeX-find-macro-end) t)))))))
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo




reply via email to

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