LaurentAUCTEX <[email protected]> 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
_______________________________________________
auctex mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/auctex