[OS X Emacs] Issue with emacs on the command line

Win Treese treese at acm.org
Thu Mar 8 14:13:46 EST 2018

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.


> On Mar 8, 2018, at 11:47 AM, Marc Shapiro -- at work <marc.shapiro at acm.org> 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

More information about the MacOSX-Emacs mailing list