Content AND Presentation

(Note to English-speaking readers: the links entitled Komentarze na tej stronie lead to comment pages.)

2016-10-22 locate-dominating-file

Some time ago there was an interesting thread on the help-gnu-emacs mailing list. Basically, the OP wanted an equivalent of save-some-buffers, only not for all files, but for the ones under version control. More generally, he wanted to be able to programmatically get the list of buffers which visit files under VC.

Go to the discussion to read about a few things Emacs can do. One of the things I learned from it was a very general function locate-dominating-file. You give it a directory name first and then a file name (it can be a directory, too, of course), and it walks the filesystem upwards from the given directory looking for a file with the given name. It then returns the name of directory containing that file (or nil when it doesn’t find any). One use-case is obvious: (locate-dominating-file "." ".git"), but I’m sure there are others. Also, you can use a predicate instead of a plain filename, so that you can e.g. search for directories containing one of .hg, .git, or do many other things. See its docstring for the nitty-gritty.

CategoryEnglish, CategoryBlog, CategoryEmacs

Comments on this page

2016-10-17 reposition-window

Did you know that you can press C-M-l to invoke the command reposition-window? Here’s an excerpt from its docstring:

Make the current definition and/or comment visible.
Further invocations move it to the top of the window or toggle the
visibility of comments that precede it.

Very useful. And since it uses the generic commands beginning-of-defun and end-of-defun, which in turn uses the variables beginning-of-defun-function and end-of-defun-function, it works in quite a few modes (including Org-mode).

CategoryEnglish, CategoryBlog, CategoryEmacs

Comments on this page

2016-10-10 Fast font changes in AUCTeX

Fast font changes in AUCTeX

This is a really simple tip, but it saves a lot of dull work. In AUCTeX, you can mark some text and press C-c C-f C-e to put an \emph around it. Type C-c C-f C-h to see other options, divided into text and math modes.

But wait, there’s more! If you precede it with an argument (i.e., C-u), instead of marking up the region, AUCTeX replaces the most nested font command around the point with the given one (disregarding the region). This means that (if the point is marked with -!-), this:

Hello \textit{wor-!-ld!}

becomes this:

Hello \emph{wor-!-ld!}

after pressing C-c C-f C-e. Also, you can press C-u C-c C-f C-d and the nearest (again, in the sense of nesting) font command disappears altogether. Very handy, and I have to admit that I miss that a lot in Org-mode (even though Org’s markup wrt fonts is much lighter).

If you have your own font changing commands, like, say, \defterm (for the defined term, possibly defined by


or something similar), you can add it to LaTeX-font-list and enjoy your own font-changing command on the C-c C-f ,,prefix’’. (It’s not really a prefix, since it just runs the TeX-font command, but that doesn’t matter now.)

CategoryEnglish, CategoryBlog, CategoryEmacs, CategoryTeX

Comments on this page


(Więcej means More in Polish; click it to see older entries.)

CategoryEnglish, CategoryBlog