diff options
| author | Xiyue Deng | 2023-12-23 16:12:44 -0800 |
|---|---|---|
| committer | Eli Zaretskii | 2023-12-24 10:38:46 +0200 |
| commit | ceacf75395834c452b43932c19df7e3202a16094 (patch) | |
| tree | 518156f5e5425c88a0224ff08b5efacb196a3861 | |
| parent | 2701da0eee54d85f79104c7a91610bf591159a51 (diff) | |
| download | emacs-ceacf75395834c452b43932c19df7e3202a16094.tar.gz emacs-ceacf75395834c452b43932c19df7e3202a16094.zip | |
Fix usage of `setq-default' and offer more suggestions
cd61af0 changed from default-major-mode to major-mode in the first
code sample but didn't change the rest. This patch fixes this and add
some explanations of why use `setq-default' instead of `setq'. In
addition, it gives background on suggesting using text-mode as default
mode and suggest other alternatives.
* doc/lispintro/emacs-lisp-intro.texi (Text and Auto-fill): Fix usage
of `setq-default' and offer more suggestions. (Bug#67848)
| -rw-r--r-- | doc/lispintro/emacs-lisp-intro.texi | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/doc/lispintro/emacs-lisp-intro.texi b/doc/lispintro/emacs-lisp-intro.texi index 4a0e8dfa1fc..26a405361de 100644 --- a/doc/lispintro/emacs-lisp-intro.texi +++ b/doc/lispintro/emacs-lisp-intro.texi | |||
| @@ -16892,8 +16892,12 @@ remember to look here to remind myself. | |||
| 16892 | @node Text and Auto-fill | 16892 | @node Text and Auto-fill |
| 16893 | @section Text and Auto Fill Mode | 16893 | @section Text and Auto Fill Mode |
| 16894 | 16894 | ||
| 16895 | Now we come to the part that turns on Text mode and | 16895 | Now we come to the part that turns on Text mode and Auto Fill |
| 16896 | Auto Fill mode. | 16896 | mode.@footnote{This section suggests settings that are more suitable |
| 16897 | for writers. For programmers, the default mode will be set to the | ||
| 16898 | corresponding prog-mode automatically based on the type of the file. | ||
| 16899 | And it's perfectly fine if you want to keep the fundamental mode as | ||
| 16900 | the default mode.} | ||
| 16897 | 16901 | ||
| 16898 | @smallexample | 16902 | @smallexample |
| 16899 | @group | 16903 | @group |
| @@ -16945,15 +16949,19 @@ Here is the line again; how does it work? | |||
| 16945 | 16949 | ||
| 16946 | @cindex Text Mode turned on | 16950 | @cindex Text Mode turned on |
| 16947 | @smallexample | 16951 | @smallexample |
| 16948 | (setq major-mode 'text-mode) | 16952 | (setq-default major-mode 'text-mode) |
| 16949 | @end smallexample | 16953 | @end smallexample |
| 16950 | 16954 | ||
| 16951 | @noindent | 16955 | @noindent |
| 16952 | This line is a short, but complete Emacs Lisp expression. | 16956 | This line is a short, but complete Emacs Lisp expression. |
| 16953 | 16957 | ||
| 16954 | We are already familiar with @code{setq}. It sets the following | 16958 | We are already familiar with @code{setq}. We use a similar macro |
| 16955 | variable, @code{major-mode}, to the subsequent value, which is | 16959 | @code{setq-default} to set the following variable, |
| 16956 | @code{text-mode}. The single-quote before @code{text-mode} tells | 16960 | @code{major-mode}@footnote{We use @code{setq-default} because |
| 16961 | @code{text-mode} is buffer local. If we use @code{setq} it will only | ||
| 16962 | apply to the current buffer, and using @code{setq-default} will also | ||
| 16963 | apply this to newly created buffers.}, to the subsequent value, which | ||
| 16964 | is @code{text-mode}. The single-quote before @code{text-mode} tells | ||
| 16957 | Emacs to deal directly with the @code{text-mode} symbol, not with | 16965 | Emacs to deal directly with the @code{text-mode} symbol, not with |
| 16958 | whatever it might stand for. @xref{setq, , Setting the Value of | 16966 | whatever it might stand for. @xref{setq, , Setting the Value of |
| 16959 | a Variable}, for a reminder of how @code{setq} works. The main point | 16967 | a Variable}, for a reminder of how @code{setq} works. The main point |