From marc.shapiro at acm.org Thu Mar 8 11:47:25 2018 From: marc.shapiro at acm.org (Marc Shapiro -- at work) Date: Thu, 8 Mar 2018 17:47:25 +0100 Subject: [OS X Emacs] Issue with emacs on the command line Message-ID: <4576B18D-8F84-4523-9966-2A49227826C8@acm.org> Hi, I wish to use Emacs on the command line. The file fixbbl.el contains the definition of interactive function "fixbbl" that does some complex editing. I tested it with an interactive Emacs with no problems. I run the following command line (on MacOS 10.13.3): /usr/bin/emacs -batch -q -l fixbbl.el -f fixbbl -f save-buffer main.bbl and it responds (No changes need to be saved) Indeed, unfortunately, the file is has not been changed. If I run interactively (i.e., without the "-batch" flag) I can see that indeed fixbbl.el has been loaded and fixbbl is defined, but has not been called; however "save-buffer" has been called, as evidenced by the response. Any idea what is wrong, or how to debug? I am appending a stripped-down version of fixbbl.el and of main.bbl in case that helps. Marc ---- fixbbl.el ---- (defun fixbbl () (interactive) (save-excursion (goto-char (point-min)) (while (re-search-forward "\\\\urldef\\\\tempurl% \\\\url{\\([^{}]+\\)} \\\\showDOI{\\\\tempurl} " nil t nil) (replace-match "\\\\showDOI{\\1}")) )) ------------------- ----- main.bbl ---- \bibitem[\protect\citeauthoryear{Ahamad, Neiger, Burns, Kohli, and Hutto}{Ahamad et~al\mbox{.}}{1995}]% {syn:mat:1025} \bibfield{author}{\bibinfo{person}{Mustaque Ahamad}, \bibinfo{person}{Gil Neiger}, \bibinfo{person}{James~E. Burns}, \bibinfo{person}{Prince Kohli}, {and} \bibinfo{person}{Phillip~W. Hutto}.} \bibinfo{year}{1995}\natexlab{}. \newblock \showarticletitle{Causal memory: definitions, implementation, and programming}. \newblock \bibinfo{journal}{\emph{Distributed Computing}} \bibinfo{volume}{9}, \bibinfo{number}{1} (\bibinfo{date}{March} \bibinfo{year}{1995}), \bibinfo{pages}{37--49}. \newblock \urldef\tempurl% \url{https://doi.org/10.1007/BF01784241} \showDOI{\tempurl} ------ From treese at acm.org Thu Mar 8 14:13:46 2018 From: treese at acm.org (Win Treese) Date: Thu, 8 Mar 2018 14:13:46 -0500 Subject: [OS X Emacs] Issue with emacs on the command line In-Reply-To: <4576B18D-8F84-4523-9966-2A49227826C8@acm.org> References: <4576B18D-8F84-4523-9966-2A49227826C8@acm.org> Message-ID: <2B013097-1766-42A4-BC1B-F4FFBA87EC50@acm.org> Hi, Marc. The problem is that your main.bbl file isn?t the current buffer when the functions are run. If you think of Emacs processing the command line arguments in order, then you need to give the file earlier in the command line: /usr/bin/emacs -batch -q main.bbl -l fixbbl.el -f fixbbl -f save-buffer From experience with other programs, it?s not obvious that the command line would be processed this way, but for doing complex things it makes a certain amount of sense. Best, Win > On Mar 8, 2018, at 11:47 AM, Marc Shapiro -- at work wrote: > > Hi, I wish to use Emacs on the command line. The file fixbbl.el contains the definition of interactive function "fixbbl" that does some complex editing. I tested it with an interactive Emacs with no problems. > > I run the following command line (on MacOS 10.13.3): > /usr/bin/emacs -batch -q -l fixbbl.el -f fixbbl -f save-buffer main.bbl > and it responds > (No changes need to be saved) > > Indeed, unfortunately, the file is has not been changed. If I run interactively (i.e., without the "-batch" flag) I can see that indeed fixbbl.el has been loaded and fixbbl is defined, but has not been called; however "save-buffer" has been called, as evidenced by the response. > > Any idea what is wrong, or how to debug? > > I am appending a stripped-down version of fixbbl.el and of main.bbl in case that helps. > > Marc > > ---- fixbbl.el ---- > > (defun fixbbl () > (interactive) > (save-excursion > (goto-char (point-min)) > (while (re-search-forward "\\\\urldef\\\\tempurl% > \\\\url{\\([^{}]+\\)} > \\\\showDOI{\\\\tempurl} > " nil t nil) > (replace-match "\\\\showDOI{\\1}")) > )) > > ------------------- > ----- main.bbl ---- > > \bibitem[\protect\citeauthoryear{Ahamad, Neiger, Burns, Kohli, and > Hutto}{Ahamad et~al\mbox{.}}{1995}]% > {syn:mat:1025} > \bibfield{author}{\bibinfo{person}{Mustaque Ahamad}, \bibinfo{person}{Gil > Neiger}, \bibinfo{person}{James~E. Burns}, \bibinfo{person}{Prince Kohli}, > {and} \bibinfo{person}{Phillip~W. Hutto}.} \bibinfo{year}{1995}\natexlab{}. > \newblock \showarticletitle{Causal memory: definitions, implementation, and > programming}. > \newblock \bibinfo{journal}{\emph{Distributed Computing}} \bibinfo{volume}{9}, > \bibinfo{number}{1} (\bibinfo{date}{March} \bibinfo{year}{1995}), > \bibinfo{pages}{37--49}. > \newblock > \urldef\tempurl% > \url{https://doi.org/10.1007/BF01784241} > \showDOI{\tempurl} > > ------ > > _____________________________________________________________ > MacOSX-Emacs mailing list > MacOSX-Emacs at email.esm.psu.edu > https://email.esm.psu.edu/mailman/listinfo/macosx-emacs > List Archives: http://dir.gmane.org/gmane.emacs.macintosh.osx From marc.shapiro at acm.org Thu Mar 8 15:18:33 2018 From: marc.shapiro at acm.org (Marc Shapiro -- at work) Date: Thu, 8 Mar 2018 21:18:33 +0100 Subject: [OS X Emacs] Issue with emacs on the command line In-Reply-To: References: Message-ID: <1E90E4BB-0663-437B-A85F-E18C19C29265@acm.org> > From: Win Treese > Subject: Re: [OS X Emacs] Issue with emacs on the command line > > Hi, Marc. The problem is that your main.bbl file isn?t the current buffer when the functions are run. If you think of Emacs processing the command line arguments in order, then you need to give the file earlier in the command line: > > /usr/bin/emacs -batch -q main.bbl -l fixbbl.el -f fixbbl -f save-buffer > > From experience with other programs, it?s not obvious that the command line would be processed this way, but for doing complex things it makes a certain amount of sense. Thanks Win, that solved the problem! Marc From iliya.lefterov at gmail.com Thu Mar 8 16:33:29 2018 From: iliya.lefterov at gmail.com (Iliya Lefterov) Date: Thu, 8 Mar 2018 16:33:29 -0500 Subject: [OS X Emacs] Issue with emacs on the command line In-Reply-To: <1E90E4BB-0663-437B-A85F-E18C19C29265@acm.org> References: <1E90E4BB-0663-437B-A85F-E18C19C29265@acm.org> Message-ID: Isn?t it the ?ideology? of Arara? Cheers! -I. On Mar 8, 2018, at 3:18 PM, Marc Shapiro -- at work wrote: From: Win Treese Subject: Re: [OS X Emacs] Issue with emacs on the command line Hi, Marc. The problem is that your main.bbl file isn?t the current buffer when the functions are run. If you think of Emacs processing the command line arguments in order, then you need to give the file earlier in the command line: /usr/bin/emacs -batch -q main.bbl -l fixbbl.el -f fixbbl -f save-buffer >From experience with other programs, it?s not obvious that the command line would be processed this way, but for doing complex things it makes a certain amount of sense. Thanks Win, that solved the problem! Marc _____________________________________________________________ MacOSX-Emacs mailing list MacOSX-Emacs at email.esm.psu.edu https://email.esm.psu.edu/mailman/listinfo/macosx-emacs List Archives: http://dir.gmane.org/gmane.emacs.macintosh.osx -------------- next part -------------- An HTML attachment was scrubbed... URL: