1
votes

Until yesterday, restarting emacs would automatically recognize .org files and switch to org-mode when viewing a .org buffer. Now I have to invoke M-x org-mode on each file. Initially, each .org mode is now in "fundamental" mode.

My ~/.emacs file contains:

(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode)) ; not needed since Emacs 22.2
(add-hook 'org-mode-hook 'turn-on-font-lock) ; not needed when global-font-lock-mode is on
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
(put 'downcase-region 'disabled nil)

I am running emacs 23.3.1 under Gnome Ubuntu 12.04 LTS.

I don't know whether emacs just got an update in 12.04, but I did accidentally run xemacs just before.

Other org-mode related lines in my ~/.emacs file are, well it appears that the line breaks aren't preserved in stack-overflow so I will omit them.

I think I figured it out. I use desktop-save. I think xemacs saved all the org files with desktop-save (when I exited) in fundamental-mode (because I don't have org-mode set up in xemacs - I really should uninstall it). In my .emacs-desktop file the org files were listed with mode "fundamental".

Deleted .emacs-desktop file ran M-x desktop-save after turning on org-mode in some org files. Those .org files for which I turned org-mode on opened with emacs in org-mode, while those I did not visit and activate org-mode stayed in fundamental mode when I restarted emacs.

Is there a way to select multiple files in the buffer list and change their modes all at once?

1
I don't use desktop-save, but can't you just delete .emacs-desktop and restart emacs without calling desktop-save? I would assume by default it would leave the modes for each file alone, unless you've explicitly changed the mode and saved the changes with a call to 'desktop-save'.Tyler

1 Answers

0
votes

To change the modes of multiple buffers, iterate using dolist over (buffer-list), possibly first filtering that list using, say, cl-remove-if-not. For each iteration, use with-current-buffer with the buffer name, and then call the mode function (e.g. (org-mode 1)):

(100% untested.)

(defun org-them ()
  "Put BUFFERS in Org mode."
  (interactive)
  (dolist (buf  (cl-remove-if-not #'SOME-TEST (buffer-list)))
    (with-current-buffer buf
      (org-mode 1))))

For example, SOME-TEST could require the last modification date to be more recent than some cutoff. Or you might be interested only in file buffers --- e.g. buffers whose buffer-file-name is matched by a regexp such as \\.org\'.