[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [AUCTeX] Jump to begin of footnote
From: |
LaurentAUCTEX |
Subject: |
Re: [AUCTeX] Jump to begin of footnote |
Date: |
Sun, 04 May 2014 17:38:02 +0200 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 |
Le 03/05/2014 11:27, Tassilo Horn a écrit :
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
_______________________________________________
auctex mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/auctex
Hi Tassilo and Igor,
Thank you very much for all these explanations. It is a good thing
to well understand how it works. I tried to resume :
;;-------------------------------
;; -----------> solution 1 :
;;-------------------------------
;; - without taking into account the cursor position outside the
braces
;; - defining explicit functions (no lambda function)
;;
(defun my-macro-start ()
(interactive)
(goto-char (TeX-find-macro-start))
(search-forward "{" (TeX-find-macro-end) t))
(global-set-key (kbd "C-c s") 'my-macro-start)
(defun my-macro-end ()
(interactive)
(goto-char (TeX-find-macro-end))
(backward-char ))
(global-set-key (kbd "C-c e") 'my-macro-end)
;;------------------------------------------------------------------
;;-------------------------
;; -----> solution 2 :
;;-------------------------
;;
;; - taking into account the cursor position outside the braces with an
;; error message (not to have the message "Wrong type argument:
integer-or-marker-p, nil")
;; - using lambdas functions
;; - the lambas functions are bound with global keys
;;
(global-set-key (kbd "C-c s")
(lambda ()
(interactive)
(let ((pos (TeX-find-macro-start)))
(if pos
(progn (goto-char pos)
(search-forward "{" (TeX-find-macro-end) t))
(print "bad cursor position")
))))
(global-set-key (kbd "C-c e")
(lambda ()
(interactive)
(let ((pos (TeX-find-macro-end)))
(if pos
(progn (goto-char pos)
(backward-char ))
(print "bad cursor position")))))
;;----------------------------------------------------------------------
;;------------------------
;;-----> solution 3 :
;;------------------------
;;
;; - taking into account the cursor position outside the braces with
;; an error message
;; - using lambdas functions
;; - the lambdas functions are not bound with global keys but are loaded
with the
;; TeX mode
;;
(add-hook 'TeX-mode-hook
(lambda ()
(local-set-key (kbd "C-c s")
(lambda ()
(interactive)
(let ((pos (TeX-find-macro-start)))
(if pos
(progn
(goto-char pos)
(search-forward "{"
(TeX-find-macro-end) t))
(print "bad cursor position")))))))
(add-hook 'TeX-mode-hook
(lambda ()
(local-set-key (kbd "C-c e")
(lambda ()
(interactive)
(let ((pos (TeX-find-macro-end)))
(if pos
(progn
(goto-char pos)
(backward-char))
(print "bad cursor position")))))))
;;----------------------------------------------------
Thank you again
Best regards
Laurent
---
Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce
que la protection avast! Antivirus est active.
http://www.avast.com