I'm using doom emacs.
It enables prettify-symbols in all modes (I think) by default, although I would like to disable it in c-mode.
I have placed the following in my config.el file:
(add-hook 'c-mode-hook (lambda ()
(prettify-symbols-mode -1)))
I have also tried this:
(add-hook 'c-mode-hook (lambda ()
(setq prettify-symbols-alist '())))
Nothing has worked, but I am able to disable it manually with M-x prettify-symbols-mode
, but I find this tedious to do every time I want to edit a c file.
Any help is appreciated.
Edit: I tried Phils's answer, to no avail. I also tried putting
(global-prettify-symbols-mode -1)
before that answer. I also did that, but changing the function definition to:
(prettify-symbols-mode -1)
Edit:
Per Phils's comment I used M-x debug-on-entry RET prettify-symbols-mode
and then opened a C file and the following traceback occurred:
Debugger entered--entering a function:
* global-prettify-symbols-mode(-1)
my-c-mode-hook()
run-hooks(change-major-mode-after-body-hook prog-mode-hook c-mode-common-hook c-mode-hook)
apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook c-mode-common-hook c-mode-hook))
run-mode-hooks(c-mode-hook)
c-mode()
set-auto-mode-0(c-mode nil)
#f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file. If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it. In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode -0x14884ef2754764cc>)()
apply(#f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file. If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it. In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode -0x14884ef2754764cc>) nil)
#f(advice-wrapper :after #f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file. If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it. In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode -0x14884ef2754764cc>) auto-minor-mode-set)()
apply(#f(advice-wrapper :after #f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file. If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it. In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode -0x14884ef2754764cc>) auto-minor-mode-set) nil)
so-long--set-auto-mode(#f(advice-wrapper :after #f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file. If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it. In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode -0x14884ef2754764cc>) auto-minor-mode-set))
apply(so-long--set-auto-mode #f(advice-wrapper :after #f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file. If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it. In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode -0x14884ef2754764cc>) auto-minor-mode-set) nil)
set-auto-mode()
normal-mode(t)
#f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x68a5324eea0fe54>)(t t)
apply(#f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x68a5324eea0fe54>) (t t))
(if (setq doom-large-file-p (and buffer-file-name (not doom-large-file-p) (file-exists-p buffer-file-name) (condition-case nil (progn (> (nth 7 (file-attributes buffer-file-name)) (* 1024 1024 (assoc-default buffer-file-name doom-large-file-size-alist ...)))) (error nil)))) (prog1 (apply orig-fn args) (if (memq major-mode doom-large-file-excluded-modes) (setq doom-large-file-p nil) (if (fboundp 'so-long-minor-mode) (progn (so-long-minor-mode 1))) (message "Large file detected! Cutting a few corners to impr..."))) (apply orig-fn args))
doom--optimize-for-large-files-a(#f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x68a5324eea0fe54>) t t)
apply(doom--optimize-for-large-files-a #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x68a5324eea0fe54>) (t t))
#f(advice-wrapper :around #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x68a5324eea0fe54>) doom--optimize-for-large-files-a)(t t)
apply(#f(advice-wrapper :around #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x68a5324eea0fe54>) doom--optimize-for-large-files-a) (t t))
#f(advice-wrapper :before #f(advice-wrapper :around #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x68a5324eea0fe54>) doom--optimize-for-large-files-a) doom-first-file-hook-h)(t t)
apply(#f(advice-wrapper :before #f(advice-wrapper :around #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x68a5324eea0fe54>) doom--optimize-for-large-files-a) doom-first-file-hook-h) (t t))
after-find-file(t t)
find-file-noselect-1(#<buffer wueygfqweu.c> "c:/Users/Username/wueygfqweu.c" nil nil "c:/Users/username/wueygfqweu.c" nil)
find-file-noselect("wueygfqweu.c" nil nil nil)
find-file("wueygfqweu.c")
evil-edit("wueygfqweu.c" nil)
funcall-interactively(evil-edit "wueygfqweu.c" nil)
call-interactively(evil-edit)
evil-ex-call-command(nil #("e" 0 1 (ex-index 1)) #("wueygfqweu.c" 0 1 (ex-index 3) 1 2 (ex-index 4) 2 3 (ex-index 5) 3 4 (ex-index 6) 4 5 (ex-index 7) 5 6 (ex-index 8) 6 7 (ex-index 9) 7 8 (ex-index 10) 8 9 (ex-index 11) 9 10 (ex-index 12) 10 11 (ex-index 13) 11 12 (ex-index 14)))
eval((evil-ex-call-command nil #("e" 0 1 (ex-index 1)) #("wueygfqweu.c" 0 1 (ex-index 3) 1 2 (ex-index 4) 2 3 (ex-index 5) 3 4 (ex-index 6) 4 5 (ex-index 7) 5 6 (ex-index 8) 6 7 (ex-index 9) 7 8 (ex-index 10) 8 9 (ex-index 11) 9 10 (ex-index 12) 10 11 (ex-index 13) 11 12 (ex-index 14))))
evil-ex-execute(#("e wueygfqweu.c" 0 1 (ex-index 1) 1 2 (ex-index 2) 2 3 (ex-index 3) 3 4 (ex-index 4) 4 5 (ex-index 5) 5 6 (ex-index 6) 6 7 (ex-index 7) 7 8 (ex-index 8) 8 9 (ex-index 9) 9 10 (ex-index 10) 10 11 (ex-index 11) 11 12 (ex-index 12) 12 13 (ex-index 13) 13 14 (ex-index 14)))
#f(compiled-function (&optional initial-input) (interactive (list (let ((s (concat (cond ((and (evil-visual-state-p) evil-ex-visual-char-range (memq (evil-visual-type) '(inclusive exclusive))) "`<,`>") ((evil-visual-state-p) "'<,'>") (current-prefix-arg (let ((arg (prefix-numeric-value current-prefix-arg))) (cond ((< arg 0) (setq arg (1+ arg))) ((> arg 0) (setq arg (1- arg)))) (if (= arg 0) "." (format ".,.%+d" arg))))) evil-ex-initial-input))) (and (> (length s) 0) s)))) #<bytecode -0x1f4f683ad84e3442>)(nil)
apply(#f(compiled-function (&optional initial-input) (interactive (list (let ((s (concat ... evil-ex-initial-input))) (and (> (length s) 0) s)))) #<bytecode -0x1f4f683ad84e3442>) nil)
(let ((completion-in-region-function #'completion--in-region)) (apply orig-fn args))
+ivy--inhibit-completion-in-region-a(#f(compiled-function (&optional initial-input) (interactive (list (let ((s (concat ... evil-ex-initial-input))) (and (> (length s) 0) s)))) #<bytecode -0x1f4f683ad84e3442>) nil)
apply(+ivy--inhibit-completion-in-region-a #f(compiled-function (&optional initial-input) (interactive (list (let ((s (concat ... evil-ex-initial-input))) (and (> (length s) 0) s)))) #<bytecode -0x1f4f683ad84e3442>) nil)
evil-ex(nil)
funcall-interactively(evil-ex nil)
call-interactively(evil-ex nil nil)
command-execute(evil-ex)
M-x debug-on-entry RET prettify-symbols-mode RET
and then open a C file. You should get a backtrace. Copy it, and edit it into your question.M-x
I am shown the backtrace. I have added it anyway.C-h i g (elisp)Debugger Commands
so you knew how to dismiss the debugger buffer, as well asM-x cancel-debug-on-entry
.after-change-major-mode-hook
though seems very much like this isglobal-prettify-symbols-mode
, per the behaviour detailed in the link in my answer. I suggest you now try adding(debug-on-entry 'global-prettify-symbols-mode)
at the very start of your init file, and then start Emacs and confirm whether something is calling it, which would be useful information.