Received: (at 26096) by debbugs.gnu.org; 15 Mar 2017 14:03:38 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 15 10:03:38 2017 Received: from localhost ([127.0.0.1]:57275 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1co9Wc-0004jD-H2 for submit <at> debbugs.gnu.org; Wed, 15 Mar 2017 10:03:38 -0400 Received: from omx11.esk.m4.zaq.ne.jp ([220.152.48.5]:55404) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <ikumikeita@HIDDEN>) id 1co9WZ-0004j2-Mx for 26096 <at> debbugs.gnu.org; Wed, 15 Mar 2017 10:03:36 -0400 Received: from omx11.esk.m4.zaq.ne.jp ([220.152.49.29] [220.152.49.29]) by omx11.esk.m4.zaq.ne.jp with ESMTP id <20170315140330742.WWUZ.3223.omx11.esk.m4.zaq.ne.jp@HIDDEN>; Wed, 15 Mar 2017 23:03:30 +0900 Received: from smtpa13.esk.m4.zaq.ne.jp ([42.144.27.116] [42.144.27.116]) by smtpa13.esk.m4.zaq.ne.jp with ESMTP id <20170315140330672.CBTL.14010.smtpa13.esk.m4.zaq.ne.jp@HIDDEN>; Wed, 15 Mar 2017 23:03:30 +0900 Received: from localhost (localhost [127.0.0.1]) by freebsd.vmware (Postfix) with ESMTP id 592FA139800; Wed, 15 Mar 2017 23:03:28 +0900 (JST) To: Didier Verna <didier@HIDDEN> Subject: Re: bug#26096: 11.90.0; Inversion of macro arguments with active region In-reply-to: Your message of "Tue, 14 Mar 2017 15:11:45 +0100." <m1o9x4q76m.fsf@HIDDEN> X-Mailer: MH-E 8.6; MH 6.8.4.JP-3.05; GNU Emacs 25.1.1 Date: Wed, 15 Mar 2017 23:03:28 +0900 Message-ID: <39423.1489586608@localhost> From: Ikumi Keita <ikumi@HIDDEN> X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 26096 Cc: 26096 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: 0.0 (/) Hi Didier, > 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). (snip) > (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! How about this one? With very breif testing, it seems to work: (defun LaTeX-fixme-active-region (optional) (TeX-argument-insert "" nil) (TeX-parse-argument optional nil)) (TeX-add-symbols '("foo" LaTeX-fixme-active-region)) The idea is very crude and ad hoc, but it does the required job anyway, at the cost that it looks as if the macro "foo" took only one argument. Regards, Ikumi Keita
bug-auctex@HIDDEN
:bug#26096
; Package auctex
.
Full text available.Received: (at 26096) by debbugs.gnu.org; 15 Mar 2017 13:46:34 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 15 09:46:33 2017 Received: from localhost ([127.0.0.1]:56427 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1co9G5-00046g-Nv for submit <at> debbugs.gnu.org; Wed, 15 Mar 2017 09:46:33 -0400 Received: from eggs.gnu.org ([208.118.235.92]:32848) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <arash@HIDDEN>) id 1co9G4-00046R-P7 for 26096 <at> debbugs.gnu.org; Wed, 15 Mar 2017 09:46:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <arash@HIDDEN>) id 1co9Fu-0001TZ-Qa for 26096 <at> debbugs.gnu.org; Wed, 15 Mar 2017 09:46:27 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:55797) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <arash@HIDDEN>) id 1co9Fu-0001TT-NQ; Wed, 15 Mar 2017 09:46:22 -0400 Received: from p54ace45c.dip0.t-ipconnect.de ([84.172.228.92]:53415 helo=MUTANT) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) (envelope-from <arash@HIDDEN>) id 1co9Fu-0005bC-4o; Wed, 15 Mar 2017 09:46:22 -0400 From: Arash Esbati <arash@HIDDEN> To: Didier Verna <didier@HIDDEN> Subject: Re: bug#26096: 11.90.0; Inversion of macro arguments with active region References: <m1o9x4q76m.fsf@HIDDEN> Date: Wed, 15 Mar 2017 14:45:38 +0100 In-Reply-To: <m1o9x4q76m.fsf@HIDDEN> (Didier Verna's message of "Tue, 14 Mar 2017 15:11:45 +0100") Message-ID: <86shmeodq5.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 26096 Cc: 26096 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -5.0 (-----) Didier Verna <didier@HIDDEN> writes: Hi Didier, > 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). Indeed, `TeX-insert-braces' is not meant to be used inside a hook. Those functions have by convention a name like `TeX-arg-...'. > 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! The way I understand the code the behavior you describe is by design: AUCTeX puts the region in the first argument when it parses t. You can check the function `TeX-parse-argument' in tex.el, line 3523, ((eq arg t) ...) So you have to write your own function, but avoid the t in the style hook. You can set the exit-mark in you function to get the same effect as with t, e.g.: (defun LaTeX-fixme-arg (optional) (insert TeX-grop) (set-marker exit-mark (point)) (insert TeX-grcl) (TeX-argument-insert (prog1 (buffer-substring (point) (mark)) (delete-region (point) (mark)) (TeX-deactivate-mark)) optional)) (TeX-add-style-hook "fixme" (lambda () (TeX-add-symbols '("foo" (TeX-arg-conditional (TeX-active-mark) (LaTeX-fixme-arg) (t nil))))) LaTeX-dialect) HTH. Best, Arash
bug-auctex@HIDDEN
:bug#26096
; Package auctex
.
Full text available.Received: (at submit) by debbugs.gnu.org; 14 Mar 2017 14:12:02 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 14 10:12:02 2017 Received: from localhost ([127.0.0.1]:55770 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1cnnBB-0000sX-5L for submit <at> debbugs.gnu.org; Tue, 14 Mar 2017 10:12:02 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53214) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <didier@HIDDEN>) id 1cnnB9-0000sK-85 for submit <at> debbugs.gnu.org; Tue, 14 Mar 2017 10:11:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <didier@HIDDEN>) id 1cnnB2-0001LW-R3 for submit <at> debbugs.gnu.org; Tue, 14 Mar 2017 10:11:53 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:37434) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <didier@HIDDEN>) id 1cnnB2-0001LP-Nt for submit <at> debbugs.gnu.org; Tue, 14 Mar 2017 10:11:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44179) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <didier@HIDDEN>) id 1cnnB1-0007yU-77 for bug-auctex@HIDDEN; Tue, 14 Mar 2017 10:11:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <didier@HIDDEN>) id 1cnnAx-0001J9-Rd for bug-auctex@HIDDEN; Tue, 14 Mar 2017 10:11:51 -0400 Received: from smtp.lrde.epita.fr ([163.5.55.2]:35327 helo=kaboul.lrde.epita.fr) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <didier@HIDDEN>) id 1cnnAx-0001IP-LL for bug-auctex@HIDDEN; Tue, 14 Mar 2017 10:11:47 -0400 Received: from uzeb.lrde.epita.fr.lrde.epita.fr (uzeb.lrde.epita.fr [192.168.101.53]) by kaboul.lrde.epita.fr (Postfix) with ESMTPS id 1818E47B19 for <bug-auctex@HIDDEN>; Tue, 14 Mar 2017 15:11:45 +0100 (CET) From: Didier Verna <didier@HIDDEN> To: bug-auctex@HIDDEN Subject: 11.90.0; Inversion of macro arguments with active region X-Attribution: dvl X-Url: http://www.lrde.epita.fr/~didier X-Web: http://www.lrde.epita.fr/~didier X-Home-Page: http://www.lrde.epita.fr/~didier Face: Date: Tue, 14 Mar 2017 15:11:45 +0100 Message-ID: <m1o9x4q76m.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -5.0 (-----) 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: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (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") ...) ) --=20 Resistance is futile. You will be jazzimilated. Lisp, Jazz, A=C3=AFkido: http://www.didierverna.info
Didier Verna <didier@HIDDEN>
:bug-auctex@HIDDEN
.
Full text available.bug-auctex@HIDDEN
:bug#26096
; Package auctex
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.