bug-auctex
[Top][All Lists]
Advanced

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

bug#26096: 11.90.0; Inversion of macro arguments with active region


From: Didier Verna
Subject: bug#26096: 11.90.0; Inversion of macro arguments with active region
Date: Tue, 14 Mar 2017 15:11:45 +0100

  Hello,

I'm trying to define a macro using the active region (when available) as
its second argument. There is no general facility for using the active
region as an argument value (to the best of my knowledge, there's only
the -1 specification, but it encompasses the macro name itself).

I found the function TeX-insert-braces which looked like it could do
what I was looking for. So I tried this:

(TeX-add-symbols '("foo" t TeX-insert-braces))

This works as expected when the region is not active, but otherwise, I
get the two arguments swapped: the contents of the active region appears
first, and then the empty pair of braces with the point inside.

I'm not sure this is a bug, because I'm not sure TeX-insert-braces can
actually be used as a hook (it would probably break when enclosed within
square brackets). However, I'm supposed to be allowed to define my own
hook, so here it is:

(defun LaTeX-fixme-active-region (optional)
  (TeX-argument-insert (if (TeX-active-mark)
                           (prog1 (buffer-substring (point) (mark))
                             (delete-region (point) (mark))
                             (deactivate-mark))
                         "")
                       optional))


Now defining my macro as follows:

(TeX-add-symbols `("foo" t LaTeX-fixme-active-region))

will entail the same behavior as with TeX-insert-braces, so I'm enclined
to call that a bug (saving the excursion won't change anything BTW).

Any comment appreciated, thanks!




Emacs  : GNU Emacs 25.2.50.1 (x86_64-apple-darwin16.3.0, NS appkit-1504.76 
Version 10.12.2 (Build 16C67))
 of 2017-01-21
Package: 11.90.0

current state:
==============
(setq
 AUCTeX-date "2017-01-11"
 window-system 'ns
 LaTeX-version "2e"
 TeX-style-path '("/usr/local/var/auctex/"
                  "/usr/local/share/emacs/emacs-packages/auctex-11.90.0/style"
                  "~/var/auctex/" "~/etc/auctex/" ".auto/" "style")
 TeX-auto-save t
 TeX-parse-self t
 TeX-master nil
 TeX-command-list '(("TeX"
                     "%(PDF)%(tex) %(file-line-error) %(extraopts) 
%`%S%(PDFout)%(mode)%' %t"
                     TeX-run-TeX nil
                     (plain-tex-mode ams-tex-mode texinfo-mode) :help
                     "Run plain TeX")
                    ("LaTeX" "%`%l%(mode)%' %t" TeX-run-TeX nil
                     (latex-mode doctex-mode) :help "Run LaTeX")
                    ("Makeinfo" "makeinfo %(extraopts) %t" TeX-run-compile nil
                     (texinfo-mode) :help "Run Makeinfo with Info output")
                    ("Makeinfo HTML" "makeinfo %(extraopts) --html %t"
                     TeX-run-compile nil (texinfo-mode) :help
                     "Run Makeinfo with HTML output")
                    ("AmSTeX" "amstex %(PDFout) %(extraopts) %`%S%(mode)%' %t"
                     TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX")
                    ("ConTeXt"
                     "%(cntxcom) --once --texutil %(extraopts) %(execopts)%t"
                     TeX-run-TeX nil (context-mode) :help "Run ConTeXt once")
                    ("ConTeXt Full" "%(cntxcom) %(extraopts) %(execopts)%t"
                     TeX-run-TeX nil (context-mode) :help
                     "Run ConTeXt until completion")
                    ("BibTeX" "bibtex %s" TeX-run-BibTeX nil t :help
                     "Run BibTeX")
                    ("Biber" "biber %s" TeX-run-Biber nil t :help "Run Biber")
                    ("View" "%V" TeX-run-discard-or-function t t :help
                     "Run Viewer")
                    ...)
 )


-- 
Resistance is futile. You will be jazzimilated.

Lisp, Jazz, Aïkido: http://www.didierverna.info





reply via email to

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