Since org-file-apps is a defcustom it won't change the values if you set them before org is loaded, if you build the list from scratch (including default values as in your second (uglier) solution) you could simply setq in your init.el and everything would work. The difference between add-hook and eval-after-load is explained here. If org is already loaded it will evaluate immediately (I mistakenly thought it ran each time a library was loaded, but it seems to be only the first time). (setcdr (assoc "\\.pdf\\'" org-file-apps) "evince %s")))Įval-after-load only evaluates the block when (require 'org) is called. pdf association directly within the alist (setcdr (assoc "\\.txt\\'" org-file-apps) "notepad.exe %s") in a future version of org, use if to avoid errors txt files aren't in the list initially, but in case that changes The if is only needed for values that aren't in the list by default, just to make sure you don't end up with conflicts somewhere down the line. It will only set the values once on startup, you won't have to worry about entries being added or not (unless you regularly reload org).Ĭombine that with setcdr and you can avoid having to delete from the list and then re-add, add if and you'll ensure that you either add or change the value. Another possible construct that could work for this would be to use eval-after-load rather than add-hook.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |