(redirected from Homepage)

Strona domowa

Witam na mojej prywatnej stronie internetowej!

[If this is all Polish to you, click here: English]

Uwaga: z oczywistych powodów nie mogę zagwarantować swojej nieomylności, choć staram się o zgodność tego, co piszę, z Prawdą. Jest również oczywiste, że nie gwarantuję takiej zgodności w przypadku komentarzy. Umieszczenie linku do strony spoza niniejszego serwisu nie musi oznaczać, że podzielam poglądy autora tej strony, a jedynie, że uważam ją za wartościową z takich czy innych powodów.

Marcin ‘mbork’ Borkowski

2015-10-03 Annoying Org-mode buffers

In the spirit of my previous post, let me share something I did just today. If I launch Org-mode agenda, it loads all agenda files (which in my case is quite a lot). If they are already opened in an Emacs session, that doesn’t do any harm; but if not, they are then all at the front of the buffer list, which I don’t like: I prefer to land where I was when I press q in agenda. Here’s a very simple function to remedy this.

(defun bury-org-buffers ()
  "Bury all Org-mode buffers."
  (mapcar (lambda (buffer)
	    (with-current-buffer buffer
	      (when (eq major-mode 'org-mode)

It is clear what and how it does. One problem is whether it is a good idea to put it into org-agenda-finalize-hook. I first did it, and then resigned. As I mentioned, the only situation this is really needed is when I start the agenda for the first time. (And if this is the first thing I do after starting Emacs, the fact that all agenda buffers are at the front of the buffer list doesn’t do any harm at all anyway, so the only moment it matters is if I launch the agenda for the first time some time after launching Emacs.)

All these considerations mean that what I really need is not a function to bury Org-mode buffers, but to load them at Emacs startup. Since I don’t restart Emacs very often (and I configured my window manager to start it right after I log in), long startup time doesn’t bother me at all.

After some time looking around in org-agenda.el, I finally found the solution. Now I just have

(org-agenda-prepare-buffers (org-agenda-files))

in my init.el.

As a final note, It might be worth mentioning that org-agenda visits agenda files using find-file-noselect. This is not exactly optimal. For instance, if one of the agenda files has unsafe file-local variables, Emacs asks the user what to do. What’s even worse, the same applies to non-agenda files which nevertheless contain one of the recent clocks. (In fact, for that it’s enough to load any Org-mode file.) Since those files might be in VC, and they might be edited by other people, and other people might be malicious, this seems to be sane behavior. Personally, I don’t mind Emacs asking me such a question on startup, but YMMV.

CategoryEnglish, CategoryBlog, CategoryEmacs, CategoryOrgMode

Comments on this page