0

After starting Emacs I see in messages buffer

Ignoring unknown mode ‘org-mode-mode’

Where can I find the culprit ? I think you should just use "org" instead of "org-mode" somewhere. But where?

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(ansi-color-faces-vector
   [default default default italic underline success warning error])
 '(ansi-color-names-vector
   ["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"])
 '(cua-mode t nil (cua-base))
 '(custom-enabled-themes '(deeper-blue))
 '(desktop-load-locked-desktop t)
 '(desktop-path '("~/.emacs.d/"))
 '(package-selected-packages '(org)))

(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(org-document-title ((t (:inherit default :weight bold :foreground "gray80" :family "Sans Serif" :height 1.6 :underline nil))))
 '(org-level-1 ((t (:inherit default :weight bold :foreground "gray80" :family "Sans Serif" :height 1.3))))
 '(org-level-2 ((t (:inherit default :weight bold :foreground "gray80" :family "Sans Serif" :height 1.2))))
 '(org-level-3 ((t (:inherit default :weight bold :foreground "gray80" :family "Sans Serif" :height 1.1))))
 '(org-level-4 ((t (:inherit default :weight bold :foreground "gray80" :family "Sans Serif"))))
 '(org-level-5 ((t (:inherit default :weight bold :foreground "gray80" :family "Sans Serif"))))
 '(org-level-6 ((t (:inherit default :weight bold :foreground "gray80" :family "Sans Serif"))))
 '(org-level-7 ((t (:inherit default :weight bold :foreground "gray80" :family "Sans Serif"))))
 '(org-level-8 ((t (:inherit default :weight bold :foreground "gray80" :family "Sans Serif")))))

;; Begin from https://github.com/james-stoup/emacs-org-mode-tutorial:

;; Must do this so the agenda knows where to look for my files
(setq org-agenda-files '("~/Org"))

;; When a TODO is set to a done state, record a timestamp
(setq org-log-done 'time)

;; Follow the links
(setq org-return-follows-link  t)

;; Associate all org files with org mode
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))

;; Make the indentation look nicer
(add-hook 'org-mode-hook 'org-indent-mode)

;; Shortcuts for storing links, viewing the agenda, and starting a capture
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(define-key global-map "\C-cc" 'org-capture)

;; Wrap the lines in org mode so that things are easier to read
(add-hook 'org-mode-hook 'visual-line-mode)

(let* ((variable-tuple
        (cond ((x-list-fonts "ETBembo")         '(:font "ETBembo"))
              ((x-list-fonts "Source Sans Pro") '(:font "Source Sans Pro"))
              ((x-list-fonts "Lucida Grande")   '(:font "Lucida Grande"))
              ((x-list-fonts "Verdana")         '(:font "Verdana"))
              ((x-family-fonts "Sans Serif")    '(:family "Sans Serif"))
              (nil (warn "Cannot find a Sans Serif Font.  Install Source Sans Pro."))))
       (base-font-color     (face-foreground 'default nil 'default))
       (headline           `(:inherit default :weight bold :foreground ,base-font-color)))

  (custom-theme-set-faces
   'user
   `(org-level-8 ((t (,@headline ,@variable-tuple))))
   `(org-level-7 ((t (,@headline ,@variable-tuple))))
   `(org-level-6 ((t (,@headline ,@variable-tuple))))
   `(org-level-5 ((t (,@headline ,@variable-tuple))))
   `(org-level-4 ((t (,@headline ,@variable-tuple))))
   `(org-level-3 ((t (,@headline ,@variable-tuple :height 1.1))))
   `(org-level-2 ((t (,@headline ,@variable-tuple :height 1.2))))
   `(org-level-1 ((t (,@headline ,@variable-tuple :height 1.3))))
   `(org-document-title ((t (,@headline ,@variable-tuple :height 1.4 :underline nil))))))

;; Remember last session
(desktop-save-mode 1)
;;(save-place-mode 1)

;; Automatically save buffer on focus out
(defun full-auto-save ()
  (interactive)
    (save-excursion
      (dolist (buf (buffer-list))
        (set-buffer buf)
        (if (and (buffer-file-name) (buffer-modified-p))
            (basic-save-buffer)))))
;;(add-hook 'auto-save-hook 'full-auto-save)
(add-hook 'focus-out-hook 'full-auto-save)

;; Adding drawer on Headline insert
(require 'org-id)

(defadvice org-insert-heading (after add-id-stuff activate)
  (template-myid))
    
(defun template-myid ()
  (save-excursion
    (insert "\n:PROPERTIES:\n:CREATED:  "
      (format-time-string "[%Y-%m-%d %a %H:%M]")
      "\n:ID:  "
      (org-id-uuid)
      "\n:END:")))

;; Collapse lists by default
(setq org-cycle-include-plain-lists 'integrate)

;; https://stackoverflow.com/questions/22200312/refile-from-one-file-to-other
;;(setq org-refile-use-outline-path 'file)              ; Top level refiles
(setq org-refile-targets '((nil :maxlevel . 9)
                                (org-agenda-files :maxlevel . 9)))
(setq org-outline-path-complete-in-steps nil)         ; Refile in a single go
(setq org-refile-use-outline-path t)                  ; Show full paths for refiling

;; Delay restoring the desktop in daemon mode until the first client connects
(add-hook 'server-after-make-frame-hook
          (lambda ()
            "Functions to apply until the first client connects"
            (desktop-read)))
5
  • 1
    Have you tried starting Emacs with the --debug-init flag? Dec 28, 2022 at 14:50
  • Yes. $ emacs --debug-init and all is clean, without any following messages.
    – Herman
    Dec 28, 2022 at 15:47
  • 2
    Check the file for a file-local mode variable, either at the top of the file or at the end.
    – NickD
    Dec 28, 2022 at 15:54
  • 3
    Ok, thanks. One .org file in buffer list contained -*- mode: org-mode -*- instead of -*- mode: org -*- . SOLVED !
    – Herman
    Dec 28, 2022 at 16:06
  • 1
    If your auto-mode-alist contains an entry assigning org-mode to files whose names have an .org suffix (as it does by default), then you don't need to specify the mode as a file local variable: you can delete that line if that's the only variable specified.
    – NickD
    Dec 28, 2022 at 16:32

1 Answer 1

1

The "Ignoring unknown mode" messages are generated by the function set-auto-mode in the file files.el. Reading the code makes it clear that the problem was a file-local mode specification: that's either a line like this:

# -*- mode: org -*-

at the top of the file, or a section like this:

# Local Variables:
# mode: org
# End:

See Specifying file variables in the Emacs manual (where BTW, it states: The special variable/value pair mode: modename;, if present, specifies a major mode (without the “-mode” suffix)).

The set-auto-mode function parses these specifications and specifically adds a suffix -mode to what it gets, so it is important to specify the mode as org, not as org-mode in these cases.

I presume (but don't know for sure) that this was an attempt to keep the file variable specification line at the top as short as possible. I also presume (but again I don't know for sure) that when these lines started becoming too long, the second mechanism (with the specification at the end of the file with one variable per line) was introduced to avoid long lines, but the shortening of the mode name was kept, for backward compatibility with the first mechanism.

As noted in a comment, if your auto-mode-alist specifies that files whose names have an .org suffix are opened in a buffer whose mode is org-mode (and by default, that is the case), then you don't need to specify the mode as a file local variable and you can delete the mode specification (or even the whole thing, if only the mode is specified).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.