reddit / emacs

Too stupid to customize modes

AB-stromer · 2022-02-16 18:48
Hi all, seems I am too stupid to customize modes for my text file editing, either via manually changing the .emacs or via M-x customize or via Easy Customize menu. Have read all online doc, internet search, "Learning GNU Emacs" book. Have tested dozens of variants given in these sources for manual changes in .emacs, but regardless which variant, when I open my file, none is active and shown in mode line. Only I managed to set fill-column via Easy Customize dialog ad the adwaita look. I simply want to have text-mode, enriched-mode, auto-fill-mode, flyspell-mode set as standard for working buffer. Here is my latest .emacs: (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. '(add-hook 'text-mode-hook t) '(ansi-color-faces-vector \[default default default italic underline success warning error\]) '(ansi-color-names-vector \["black" "red3" "ForestGreen" "yellow3" "blue" "magenta3" "DeepSkyBlue" "gray50"\]) '(custom-enabled-themes '(adwaita)) '(display-fill-column-indicator t) '(fill-column 75) '(add-hook 'text-mode-hook 'auto-fill-mode) '(add-hook 'text-mode-hook 'enriched-mode) '(add-hook 'text-mode-hook 'flyspell-mode)) (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. ) If anyone could advise, I would be happy!
00-11 · 2022-02-16 19:14
Please format your code, to start with - indent it all 4 spaces. Thx.
[deleted] · 2022-02-16 19:23
[deleted]
AB-stromer · 2022-02-16 19:28
Done, but makes no change ..
arthurno1 · 2022-02-16 19:30
When you press edit comment there is a button above the text box, that looks like this: '<>'. Select your code in the text box, press that button and then press the "save" button below the text box, and your code should look ok.
thetemp_ · 2022-02-16 20:08
(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. '(add-hook 'text-mode-hook t) '(ansi-color-faces-vector [default default default italic underline success warning error]) '(ansi-color-names-vector ["black" "red3" "ForestGreen" "yellow3" "blue" "magenta3" "DeepSkyBlue" "gray50"]) '(custom-enabled-themes '(adwaita)) '(display-fill-column-indicator t) '(fill-column 75) '(add-hook 'text-mode-hook 'auto-fill-mode) '(add-hook 'text-mode-hook 'enriched-mode) '(add-hook 'text-mode-hook 'flyspell-mode)) (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. ) It looks like you've done exactly what the commented part of the `custom-set-variables` statement says not to do. The lines that begin with `'(add-hook 'text-mode-hook` weren't placed there by the Custom interface. You need to remove the 4 lines that begin with `'(add-hook 'text-mode-hook` (but be sure to leave the closing parenthesis at the end of the last one). You don't want to set a variable named "add-hook", because there is no such variable. "add-hook" is a function that's used for adding items to a hook variable. In order to set the text-mode-hook variable, you can either use the `add-hook` function, or you can do it through Custom... but not both. If you want to manually edit your init file, you could use `add-hook`. But it must be *outside* of the `custom-set-variables` statement. You could just paste the last 3 "add-hook" lines somewhere else in your config, without the quote. Like this: (add-hook 'text-mode-hook 'auto-fill-mode) (add-hook 'text-mode-hook 'enriched-mode) (add-hook 'text-mode-hook 'flyspell-mode) Or, if you want to add those functions to `text-mode-hook` using the Custom interface, do "M-x customize-variable <return> text-mode-hook <return>", then use the interface to insert those functions on the hook. And then click the "Apply and Save" button. The Custom interface will edit the `custom-set-variables` statement for you. You generally shouldn't edit it directly.
7890yuiop · 2022-02-17 00:39
The only code formatting method which works for all of reddit is to switch the reddit editor to markdown mode and indent the code by 4 spaces (you can use `M-4 C-x C-i` on a region followed by `M-x untabify` to achieve this in Emacs). Otherwise for lots of readers your message looks like this: https://old.reddit.com/r/emacs/comments/su36l6/too_stupid_to_customize_modes/ It's probably the "switch the reddit editor to markdown mode" step you were missing.
redguardtoo · 2022-02-17 01:52
You need read some tutorial to learn basics, try this book, https://www.masteringemacs.org/
AB-stromer · 2022-02-17 06:39
> "M-x customize-variable <return> text-mode-hook <return>" Did it this way and it works! :-) Have seen this nowhere in all mentioned documentation... Thanks a lot for helping!
thetemp_ · 2022-02-17 17:36
You're welcome! > Have seen this nowhere in all mentioned documentation... It's [here](https://www.gnu.org/software/emacs/manual/html_node/emacs/Specific-Customization.html), but there's a lot of documentation. You can also get to it via the menu-bar, "Options -> Customize Emacs -> Specific Option". If you're just learning Emacs, I'd recommend focusing on how to use the built-in help (describe-variable, describe-function, etc.) and the Info documentation. Once you master that, finding out how to do things becomes a lot easier. Start with the tutorial if you haven't already ("C-h t"). Have fun!