For the English part of the blog, see Content AND Presentation.

2020-09-20 A simple trick with Textern and require-final-newline

I have been using the Textern add-on for Firefox for quite some time now. What it does is it lets you press some key combination while being focused on a textarea element and start editing it in an editor of your choice. Of course, the editor of my choice is Emacs (well actually, Firefox thinks it’s emacsclient, of course). However, there was one thing that annoyed me. By default, Emacs sets require-final-newline to t in text mode and the modes derived from it, like Markdown mode (well, actually it sets it to mode-require-final-newline, which is t by default, but that’s another story). This is good when editing actual text files (which I want to end with a newline), but bad when editing a one-line chat message using Emacs via Textern.

Of course, this is Emacs, so it turns out that it is actually very easy to fix. What I did was this: I configured Textern to use as the temporary file extension, and added this to my init.el:

 (lambda ()
   (when (string-match "\\.textern\\.md$" (buffer-file-name))
     (setq require-final-newline nil))))

And that’s it! The cool bit is that it only took me five minutes of work, and I didn’t even have to restart Emacs to benefit from this little improvement.

CategoryEnglish, CategoryBlog, CategoryEmacs

Comments on this page

2020-09-14 amsreftex – a long-expected package

I have been a long time user of the amsrefs LaTeX package. I am also an avid fan of the AUCTeX Emacs package. Unfortunately, the two don’t get along very well with each other – AUCTeX has RefTeX, which assumes that the bibliographies are done with BibTeX (and possibly also works with BibLaTeX). This makes RefTeX basically useless for me.

And that was the situation until a few days ago. I received an email from Fran Burstall saying that he implemented support for amsrefs in RefTeX.

I downloaded his library today and started playing around with it. I did not spend a lot of time with it, but from what I see it works pretty well. The first feature I used was C-c [, which lets me enter a citation. It accepts a regex – and displays a window with all the entries matching that regex. “Matching” here means matching the author, title, journal title, publisher – basically whatever, which is great. I can select one of them, and even mark a few and insert a \cite{...,...} command with them (amsrefs’ \citelist is not supported, but this can be easily remedied).

Another feature which I really love is Eldoc-like info about the citation at point. (For it to work, you need to place the point on the label itself – the \cite command is not enough.) One its drawback is that it does not show the type of the entry (book/article/website etc.), but since it shows the author and title, it is not a big issue. (Also, for this to work you need to press C-c & on a citation; presumably, RefTeX then “loads” the bibliography into its memory.)

I did not check how amsreftex works with a bibliography in a separate file – I never use that feature of amsrefs anyway – but using a master file which includes e.g. chapters and bibliography as separate files works just fine.

It is really a pity I use TeX less and less these days, as I am no longer involved in academia (in fact, I like to describe myself half-jokingly as a “former mathematician”;-)). If I were, amsreftex is something I would use on a daily basis, and I cannot recommend it enough if you happen to use the trio of Emacs, AUCTeX and amsrefs.

Good job, Fran! Thank you!

CategoryEnglish, CategoryBlog, CategoryEmacs, CategoryTeX, CategoryLaTeX

Comments on this page

2020-09-05 Better look of the ivy-occur-grep buffer

Continuing the trend of short tips due to lots of work I have nowadays, here is one thing that bothered me for some time and how I fixed it.

I use Ivy and Counsel a lot. One of the functions I have even bound to an easily accessible key is counsel-rg. Within it, I often use C-c C-o, which is bound to ivy-occur, which uses the string I have entered to create an occur buffer with all the matches shown. However, in some of the projects I work on, the lines in various files tend to be quite long (sometimes on the order of a few kilobytes!), and the occur buffer is a bit unwieldy then. 99% of the time the first thing I did in it was to run toggle-truncate-lines. One day, it occurred to me (lame pun intended, SCNR) that I should really make Emacs do that for me. A minute or two of searching for the right hook resulted in this snippet I have put in my init.el:

(add-hook 'ivy-occur-grep-mode-hook
	  (lambda () (toggle-truncate-lines 1)))

and now I’m a happier Ivy/Counsel user.

CategoryEnglish, CategoryBlog, CategoryEmacs

Comments on this page