* bug#67848: 29.1; Fix usage of `setq-default' and add explanation @ 2023-12-16 11:18 Xiyue Deng 2023-12-16 11:26 ` Xiyue Deng 2023-12-23 9:00 ` Eli Zaretskii 0 siblings, 2 replies; 7+ messages in thread From: Xiyue Deng @ 2023-12-16 11:18 UTC (permalink / raw) To: 67848 In the lisp intro book, there is a discrepancy in the section "Text and Auto Fill mode" where the first code example uses "(setq-default major-mode 'text-mode)"[1] but in the later explanation part the function was changed to `setq'[2]. It looks like the original change[3] was to deprecate the usage of "default-major-mode", but forgot to update the other part. I have prepared a patch to make it consistent, and also added some extra text to explain why `setq-default' is required for a buffer local variable using a foot note. Will add in the next mail. [1] https://git.savannah.gnu.org/cgit/emacs.git/tree/doc/lispintro/emacs-lisp-intro.texi#n16902 [2] https://git.savannah.gnu.org/cgit/emacs.git/tree/doc/lispintro/emacs-lisp-intro.texi#n16946 [3] https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=cd61af01c1220b6a7f98189c826edc7535416583 In GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.37, cairo version 1.16.0) of 2023-09-19, modified by Debian built on debian-hx90 System Description: Debian GNU/Linux 12 (bookworm) Configured using: 'configure --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/libexec --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --with-libsystemd --with-pop=yes --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/29.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/29.1/site-lisp:/usr/share/emacs/site-lisp --with-sound=alsa --without-gconf --with-mailutils --with-native-compilation --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/libexec --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --with-libsystemd --with-pop=yes --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/29.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/29.1/site-lisp:/usr/share/emacs/site-lisp --with-sound=alsa --without-gconf --with-mailutils --with-native-compilation --with-cairo --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2 -ffile-prefix-map=/build/emacs-bYKTEl/emacs-29.1+1=. -fstack-protector-strong -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Texinfo/P Minor modes in effect: TeX-PDF-mode: t global-git-commit-mode: t magit-auto-revert-mode: t shell-dirtrack-mode: t windmove-mode: t flyspell-mode: t rcirc-track-minor-mode: t server-mode: t bug-reference-prog-mode: t global-company-mode: t company-mode: t global-treesit-auto-mode: t icomplete-mode: t fido-mode: t override-global-mode: t global-display-line-numbers-mode: t display-line-numbers-mode: t global-auto-revert-mode: t tooltip-mode: t global-eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t tab-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t column-number-mode: t line-number-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: /usr/share/emacs/site-lisp/elpa/debian-el-37.11/debian-el-autoloads hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37.11/debian-el-autoloads /usr/share/emacs/site-lisp/elpa/debian-el-37.11/apt-sources hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37.11/apt-sources /usr/share/emacs/site-lisp/elpa/debian-el-37.11/debian-bug hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37.11/debian-bug /usr/share/emacs/site-lisp/elpa/debian-el-37.11/apt-utils hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37.11/apt-utils /usr/share/emacs/site-lisp/elpa/debian-el-37.11/debian-el-pkg hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37.11/debian-el-pkg /usr/share/emacs/site-lisp/elpa/debian-el-37.11/gnus-BTS hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37.11/gnus-BTS /usr/share/emacs/site-lisp/elpa/debian-el-37.11/deb-view hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37.11/deb-view /usr/share/emacs/site-lisp/elpa/debian-el-37.11/debian-el hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37.11/debian-el /usr/share/emacs/site-lisp/elpa/debian-el-37.11/preseed hides /usr/share/emacs/site-lisp/elpa-src/debian-el-37.11/preseed /usr/share/emacs/site-lisp/elpa/devscripts-40/devscripts hides /usr/share/emacs/site-lisp/elpa-src/devscripts-40/devscripts /usr/share/emacs/site-lisp/elpa/devscripts-40/devscripts-autoloads hides /usr/share/emacs/site-lisp/elpa-src/devscripts-40/devscripts-autoloads /usr/share/emacs/site-lisp/elpa/devscripts-40/pbuilder-mode hides /usr/share/emacs/site-lisp/elpa-src/devscripts-40/pbuilder-mode /usr/share/emacs/site-lisp/elpa/devscripts-40/devscripts-pkg hides /usr/share/emacs/site-lisp/elpa-src/devscripts-40/devscripts-pkg /usr/share/emacs/site-lisp/elpa/devscripts-40/pbuilder-log-view-mode hides /usr/share/emacs/site-lisp/elpa-src/devscripts-40/pbuilder-log-view-mode /usr/share/emacs/site-lisp/elpa/dockerfile-mode-1.7/dockerfile-mode hides /usr/share/emacs/site-lisp/elpa-src/dockerfile-mode-1.7/dockerfile-mode /usr/share/emacs/site-lisp/elpa/dockerfile-mode-1.7/dockerfile-mode-autoloads hides /usr/share/emacs/site-lisp/elpa-src/dockerfile-mode-1.7/dockerfile-mode-autoloads /usr/share/emacs/site-lisp/elpa/dockerfile-mode-1.7/dockerfile-mode-pkg hides /usr/share/emacs/site-lisp/elpa-src/dockerfile-mode-1.7/dockerfile-mode-pkg /usr/share/emacs/site-lisp/elpa/dpkg-dev-el-37.10/debian-bts-control hides /usr/share/emacs/site-lisp/elpa-src/dpkg-dev-el-37.10/debian-bts-control /usr/share/emacs/site-lisp/elpa/dpkg-dev-el-37.10/debian-changelog-mode hides /usr/share/emacs/site-lisp/elpa-src/dpkg-dev-el-37.10/debian-changelog-mode /usr/share/emacs/site-lisp/elpa/dpkg-dev-el-37.10/dpkg-dev-el-autoloads hides /usr/share/emacs/site-lisp/elpa-src/dpkg-dev-el-37.10/dpkg-dev-el-autoloads /usr/share/emacs/site-lisp/elpa/dpkg-dev-el-37.10/dpkg-dev-el-pkg hides /usr/share/emacs/site-lisp/elpa-src/dpkg-dev-el-37.10/dpkg-dev-el-pkg /usr/share/emacs/site-lisp/elpa/dpkg-dev-el-37.10/dpkg-dev-el hides /usr/share/emacs/site-lisp/elpa-src/dpkg-dev-el-37.10/dpkg-dev-el /usr/share/emacs/site-lisp/elpa/dpkg-dev-el-37.10/debian-control-mode hides /usr/share/emacs/site-lisp/elpa-src/dpkg-dev-el-37.10/debian-control-mode /usr/share/emacs/site-lisp/elpa/dpkg-dev-el-37.10/debian-copyright hides /usr/share/emacs/site-lisp/elpa-src/dpkg-dev-el-37.10/debian-copyright /usr/share/emacs/site-lisp/elpa/dpkg-dev-el-37.10/readme-debian hides /usr/share/emacs/site-lisp/elpa-src/dpkg-dev-el-37.10/readme-debian /usr/share/emacs/site-lisp/elpa/lintian-0.1/lintian-pkg hides /usr/share/emacs/site-lisp/elpa-src/lintian-0.1/lintian-pkg /usr/share/emacs/site-lisp/elpa/lintian-0.1/lintian-autoloads hides /usr/share/emacs/site-lisp/elpa-src/lintian-0.1/lintian-autoloads /usr/share/emacs/site-lisp/elpa/lintian-0.1/lintian hides /usr/share/emacs/site-lisp/elpa-src/lintian-0.1/lintian /usr/share/emacs/site-lisp/elpa/po-mode-0.21/po-mode-pkg hides /usr/share/emacs/site-lisp/elpa-src/po-mode-0.21/po-mode-pkg /usr/share/emacs/site-lisp/elpa/po-mode-0.21/po-mode-autoloads hides /usr/share/emacs/site-lisp/elpa-src/po-mode-0.21/po-mode-autoloads /usr/share/emacs/site-lisp/elpa/po-mode-0.21/po-mode hides /usr/share/emacs/site-lisp/elpa-src/po-mode-0.21/po-mode /usr/share/emacs/site-lisp/elpa/py-isort-2016.1/py-isort hides /usr/share/emacs/site-lisp/elpa-src/py-isort-2016.1/py-isort /usr/share/emacs/site-lisp/elpa/py-isort-2016.1/py-isort-autoloads hides /usr/share/emacs/site-lisp/elpa-src/py-isort-2016.1/py-isort-autoloads /usr/share/emacs/site-lisp/elpa/py-isort-2016.1/py-isort-pkg hides /usr/share/emacs/site-lisp/elpa-src/py-isort-2016.1/py-isort-pkg /home/xiyueden/.config/emacs/elpa/transient-0.5.2/transient hides /usr/share/emacs/29.1/lisp/transient Features: (shadow emacsbug cl-print shortdoc tex-info tex texmathp texinfo texinfo-loaddefs help-fns radix-tree magit-patch magit-subtree magit-gitignore magit-ediff ediff ediff-merg ediff-mult ediff-wind ediff-diff ediff-help ediff-init ediff-util make-mode debian-control-mode debian-bug debian-changelog-mode goto-addr misearch multi-isearch apropos url-http url-gw url-auth url-queue url-cache shr-color vterm magit-bookmark bookmark tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat term ehelp vterm-module git-rebase eglot external-completion array jsonrpc ert ewoc debug backtrace find-func magit-extras face-remap magit-submodule magit-obsolete magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit magit-sequence magit-notes magit-worktree magit-tag magit-merge magit-branch magit-reset magit-files magit-refs magit-status magit magit-repos magit-apply magit-wip magit-log which-func imenu magit-diff smerge-mode diff git-commit log-edit add-log magit-core magit-autorevert magit-margin magit-transient magit-process with-editor shell pcomplete magit-mode transient edmacro kmacro compat format-spec magit-git magit-section mailalias dired-aux flow-fill qp matlab matlab-scan matlab-syntax matlab-compat pulse color mm-archive magit-utils crm dash mule-util jka-compr sort gnus-cite mail-extr textsec uni-scripts idna-mapping ucs-normalize uni-confusable textsec-check gnus-async gnus-bcklg gnus-ml gnus-topic cursor-sensor utf-7 nnfolder gnus-demon nnml ezgnus gnus-delay gnus-draft gnus-agent gnus-srvr gnus-score score-mode nnvirtual nntp gnus-cache gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-sum shr pixel-fill kinsoku url-file svg dom nndraft nnmh gnus-group gnus-undo smtpmail gnus-start gnus-dbus dbus xml gnus-cloud nnimap nnmail mail-source utf7 nnoo gnus-spec gnus-int gnus-range message sendmail yank-media dired dired-loaddefs rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev gmm-utils mailheader gnus-win gnus nnheader gnus-util mail-utils range mm-util mail-prsvr windmove flyspell ispell gnutls network-stream puny nsm epa-file epa derived epg rfc6068 epg-config rcirc parse-time iso8601 time-date term/xterm xterm comp comp-cstr rx server cap-words superword subword vc-hg vc-git diff-mode vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs log-view pcvs-util vc vc-dispatcher bug-reference disp-table whitespace yasnippet cus-edit pp cus-start wid-edit company-oddmuse company-keywords company-etags etags fileloop generator xref company-gtags company-dabbrev-code company-dabbrev company-files company-clang company-capf company-cmake company-semantic company-template company-bbdb company pcase init zenburn-theme treesit-auto treesit keychain-environment exec-path-from-shell icomplete cus-load flymake-proc flymake project compile text-property-search comint ansi-osc ansi-color ring warnings icons thingatpt advice cl-extra help-mode use-package use-package-ensure use-package-delight use-package-diminish use-package-bind-key bind-key easy-mmode use-package-core display-line-numbers autorevert filenotify apache-mode-autoloads auctex-autoloads tex-site bison-mode-autoloads boxquote-autoloads cargo-autoloads cmake-mode-autoloads company-autoloads csv-mode-autoloads dart-mode-autoloads exec-path-from-shell-autoloads flutter-autoloads format-all-autoloads git-modes-autoloads gnuplot-autoloads go-mode-autoloads graphviz-dot-mode-autoloads inheritenv-autoloads keychain-environment-autoloads language-id-autoloads magit-autoloads git-commit-autoloads magit-section-autoloads dash-autoloads matlab-mode-autoloads meson-mode-autoloads nginx-mode-autoloads pyvenv-autoloads rust-mode-autoloads scala-mode-autoloads transient-autoloads treesit-auto-autoloads vterm-autoloads with-editor-autoloads compat-autoloads xclip-autoloads yaml-mode-autoloads yasnippet-autoloads zenburn-theme-autoloads info debian-el-autoloads dpkg-dev-el-autoloads package browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs password-cache json subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit xinput2 x multi-tty make-network-process native-compile emacs) Memory information: ((conses 16 1373649 182645) (symbols 48 37295 55) (strings 32 173976 29539) (string-bytes 1 6912179) (vectors 16 101557) (vector-slots 8 2425275 106882) (floats 8 704 2874) (intervals 56 53218 7615) (buffers 984 90)) ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#67848: 29.1; Fix usage of `setq-default' and add explanation 2023-12-16 11:18 bug#67848: 29.1; Fix usage of `setq-default' and add explanation Xiyue Deng @ 2023-12-16 11:26 ` Xiyue Deng 2023-12-23 9:00 ` Eli Zaretskii 1 sibling, 0 replies; 7+ messages in thread From: Xiyue Deng @ 2023-12-16 11:26 UTC (permalink / raw) To: 67848 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: 0001-Fix-usage-of-setq-default-and-add-explanation-bug-67.patch --] [-- Type: text/x-diff, Size: 1903 bytes --] From 197467583063492dee7bc2fc40709ecb3a3d17e9 Mon Sep 17 00:00:00 2001 From: Xiyue Deng <manphiz@gmail.com> Date: Sat, 16 Dec 2023 02:06:15 -0800 Subject: [PATCH] Fix usage of `setq-default' and add explanation (bug#67848) cd61af0 changed from default-major-mode to major-mode in the first code sample but didn't change the rest. Fix it here and add some explanations of why use `setq-default' instead of `setq'. * doc/lispintro/emacs-lisp-intro.texi (Text and Auto-fill): fix `setq' to `setq-default' and add some explanations. --- doc/lispintro/emacs-lisp-intro.texi | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/lispintro/emacs-lisp-intro.texi b/doc/lispintro/emacs-lisp-intro.texi index eb8ff413b79..2468571eb96 100644 --- a/doc/lispintro/emacs-lisp-intro.texi +++ b/doc/lispintro/emacs-lisp-intro.texi @@ -16943,14 +16943,19 @@ Here is the line again; how does it work? @cindex Text Mode turned on @smallexample -(setq major-mode 'text-mode) +(setq-default major-mode 'text-mode) @end smallexample @noindent This line is a short, but complete Emacs Lisp expression. -We are already familiar with @code{setq}. It sets the following variable, -@code{major-mode}, to the subsequent value, which is @code{text-mode}. +We are already familiar with @code{setq}. We use a similar macro +@code{setq-default} to set the following variable, +@code{major-mode}@footnote{We use @code{setq-default} because +@code{text-mode} is buffer local. If we use @code{setq} it will only +apply to the current buffer, and using @code{setq-default} will also +apply this to newly created buffers.}, to the subsequent value, which is +@code{text-mode}. The single-quote before @code{text-mode} tells Emacs to deal directly with the @code{text-mode} symbol, not with whatever it might stand for. @xref{set & setq, , Setting the Value of a Variable}, -- 2.39.2 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#67848: 29.1; Fix usage of `setq-default' and add explanation 2023-12-16 11:18 bug#67848: 29.1; Fix usage of `setq-default' and add explanation Xiyue Deng 2023-12-16 11:26 ` Xiyue Deng @ 2023-12-23 9:00 ` Eli Zaretskii 2023-12-23 10:09 ` Xiyue Deng 1 sibling, 1 reply; 7+ messages in thread From: Eli Zaretskii @ 2023-12-23 9:00 UTC (permalink / raw) To: Xiyue Deng; +Cc: 67848 > From: Xiyue Deng <manphiz@gmail.com> > Date: Sat, 16 Dec 2023 03:18:20 -0800 > > > In the lisp intro book, there is a discrepancy in the section "Text and > Auto Fill mode" where the first code example uses "(setq-default > major-mode 'text-mode)"[1] but in the later explanation part the > function was changed to `setq'[2]. It looks like the original change[3] > was to deprecate the usage of "default-major-mode", but forgot to update > the other part. > > I have prepared a patch to make it consistent, and also added some extra > text to explain why `setq-default' is required for a buffer local > variable using a foot note. Will add in the next mail. Thanks, but I think it's wrong to use setq-default here, since that makes Text mode the default major-mode (instead of Fundamental), which is not what most people would want. I think we should instead do one of the following: . convert the _first_ setq-default to setq . do as above, and also explain that people who really want Emacs to start new buffers in Text mode should use setq-default Would you like to amend your patch along these lines? ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#67848: 29.1; Fix usage of `setq-default' and add explanation 2023-12-23 9:00 ` Eli Zaretskii @ 2023-12-23 10:09 ` Xiyue Deng 2023-12-23 11:20 ` Eli Zaretskii 0 siblings, 1 reply; 7+ messages in thread From: Xiyue Deng @ 2023-12-23 10:09 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 67848 Eli Zaretskii <eliz@gnu.org> writes: >> From: Xiyue Deng <manphiz@gmail.com> >> Date: Sat, 16 Dec 2023 03:18:20 -0800 >> >> >> In the lisp intro book, there is a discrepancy in the section "Text and >> Auto Fill mode" where the first code example uses "(setq-default >> major-mode 'text-mode)"[1] but in the later explanation part the >> function was changed to `setq'[2]. It looks like the original change[3] >> was to deprecate the usage of "default-major-mode", but forgot to update >> the other part. >> >> I have prepared a patch to make it consistent, and also added some extra >> text to explain why `setq-default' is required for a buffer local >> variable using a foot note. Will add in the next mail. > > Thanks, but I think it's wrong to use setq-default here, since that > makes Text mode the default major-mode (instead of Fundamental), which > is not what most people would want. Actually making text-mode the default mode for new files is exactly what the author intended based on the text from an earlier section[1]. In addition, the previous change was to deprecate `default-major-mode' which used to achieve the same effect. So it looks like that the intention to change the default major-mode for new files is consistent through the text. Of course, whether this is a good advice is a slightly different matter, and may be worth discussing in a footnote if it sounds worth doing. But based on the text flow setting the new default major-mode should not be changed IMHO. > > I think we should instead do one of the following: > > . convert the _first_ setq-default to setq > . do as above, and also explain that people who really want Emacs to > start new buffers in Text mode should use setq-default > > Would you like to amend your patch along these lines? [1] https://git.savannah.gnu.org/cgit/emacs.git/tree/doc/lispintro/emacs-lisp-intro.texi#n16569 -- Xiyue Deng ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#67848: 29.1; Fix usage of `setq-default' and add explanation 2023-12-23 10:09 ` Xiyue Deng @ 2023-12-23 11:20 ` Eli Zaretskii 2023-12-24 7:00 ` Xiyue Deng 0 siblings, 1 reply; 7+ messages in thread From: Eli Zaretskii @ 2023-12-23 11:20 UTC (permalink / raw) To: Xiyue Deng; +Cc: 67848 > From: Xiyue Deng <manphiz@gmail.com> > Cc: 67848@debbugs.gnu.org > Date: Sat, 23 Dec 2023 02:09:29 -0800 > > Eli Zaretskii <eliz@gnu.org> writes: > > >> From: Xiyue Deng <manphiz@gmail.com> > >> Date: Sat, 16 Dec 2023 03:18:20 -0800 > >> > >> > > Thanks, but I think it's wrong to use setq-default here, since that > > makes Text mode the default major-mode (instead of Fundamental), which > > is not what most people would want. > > Actually making text-mode the default mode for new files is exactly what > the author intended based on the text from an earlier section[1]. I know, but I don't want that to be said without reservations, or not at all. The author's hope was that there will be many readers of this manual who are not programmers, and who would then prefer Text mode as the default. We are now a few decades wiser, and we know that hope didn't really materialize. So we should not advertise such a setting without some explanations. > Of course, whether this is a good advice is a slightly different matter, > and may be worth discussing in a footnote if it sounds worth doing. But > based on the text flow setting the new default major-mode should not be > changed IMHO. Sorry, I disagree, for the reasons explained above. Thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#67848: 29.1; Fix usage of `setq-default' and add explanation 2023-12-23 11:20 ` Eli Zaretskii @ 2023-12-24 7:00 ` Xiyue Deng 2023-12-24 8:47 ` Eli Zaretskii 0 siblings, 1 reply; 7+ messages in thread From: Xiyue Deng @ 2023-12-24 7:00 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 67848 [-- Attachment #1: Type: text/plain, Size: 1694 bytes --] Eli Zaretskii <eliz@gnu.org> writes: >> From: Xiyue Deng <manphiz@gmail.com> >> Cc: 67848@debbugs.gnu.org >> Date: Sat, 23 Dec 2023 02:09:29 -0800 >> >> Eli Zaretskii <eliz@gnu.org> writes: >> >> >> From: Xiyue Deng <manphiz@gmail.com> >> >> Date: Sat, 16 Dec 2023 03:18:20 -0800 >> >> >> >> >> > Thanks, but I think it's wrong to use setq-default here, since that >> > makes Text mode the default major-mode (instead of Fundamental), which >> > is not what most people would want. >> >> Actually making text-mode the default mode for new files is exactly what >> the author intended based on the text from an earlier section[1]. > > I know, but I don't want that to be said without reservations, or not > at all. The author's hope was that there will be many readers of this > manual who are not programmers, and who would then prefer Text mode as > the default. We are now a few decades wiser, and we know that hope > didn't really materialize. So we should not advertise such a setting > without some explanations. While I kind of agree with what you said here, this requires a much larger rewrite of the text, because there are several paragraphs that span several sections that follows the author's original advice of making newly opened files to use text-mode instead of fundamental mode by default. Neither being a writer, nor even a native English speaker, I don't consider myself a good candidate to make such a drastic change to this classic book. So instead I added another footnote at the first sentence of this section to suggest that the suggestion was aimed for writers and the reader can feel free not to do this. The new patch is attached. PTAL. -- Xiyue Deng [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-Fix-usage-of-setq-default-and-offer-more-suggestions.patch --] [-- Type: text/x-diff, Size: 2723 bytes --] From d5e89a19ee7fcfe2aa6bb35f5ad84eb17819408b Mon Sep 17 00:00:00 2001 From: Xiyue Deng <manphiz@gmail.com> Date: Sat, 23 Dec 2023 16:12:44 -0800 Subject: [PATCH] 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) --- doc/lispintro/emacs-lisp-intro.texi | 20 ++++++++++++++------ 1 file 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. @node Text and Auto-fill @section Text and Auto Fill Mode -Now we come to the part that turns on Text mode and -Auto Fill mode. +Now we come to the part that turns on Text mode and Auto Fill +mode.@footnote{This section suggests settings that are more suitable +for writers. For programmers, the default mode will be set to the +corresponding prog-mode automatically based on the type of the file. +And it's perfectly fine if you want to keep the fundamental mode as +the default mode.} @smallexample @group @@ -16945,15 +16949,19 @@ Here is the line again; how does it work? @cindex Text Mode turned on @smallexample -(setq major-mode 'text-mode) +(setq-default major-mode 'text-mode) @end smallexample @noindent This line is a short, but complete Emacs Lisp expression. -We are already familiar with @code{setq}. It sets the following -variable, @code{major-mode}, to the subsequent value, which is -@code{text-mode}. The single-quote before @code{text-mode} tells +We are already familiar with @code{setq}. We use a similar macro +@code{setq-default} to set the following variable, +@code{major-mode}@footnote{We use @code{setq-default} because +@code{text-mode} is buffer local. If we use @code{setq} it will only +apply to the current buffer, and using @code{setq-default} will also +apply this to newly created buffers.}, to the subsequent value, which +is @code{text-mode}. The single-quote before @code{text-mode} tells Emacs to deal directly with the @code{text-mode} symbol, not with whatever it might stand for. @xref{setq, , Setting the Value of a Variable}, for a reminder of how @code{setq} works. The main point -- 2.39.2 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#67848: 29.1; Fix usage of `setq-default' and add explanation 2023-12-24 7:00 ` Xiyue Deng @ 2023-12-24 8:47 ` Eli Zaretskii 0 siblings, 0 replies; 7+ messages in thread From: Eli Zaretskii @ 2023-12-24 8:47 UTC (permalink / raw) To: Xiyue Deng; +Cc: 67848-done > From: Xiyue Deng <manphiz@gmail.com> > Cc: 67848@debbugs.gnu.org > Date: Sat, 23 Dec 2023 23:00:59 -0800 > > While I kind of agree with what you said here, this requires a much > larger rewrite of the text, because there are several paragraphs that > span several sections that follows the author's original advice of > making newly opened files to use text-mode instead of fundamental mode > by default. Neither being a writer, nor even a native English speaker, > I don't consider myself a good candidate to make such a drastic change > to this classic book. > > So instead I added another footnote at the first sentence of this > section to suggest that the suggestion was aimed for writers and the > reader can feel free not to do this. The new patch is attached. PTAL. Thanks, installed on the emacs-29 branch, and closing the bug. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-12-24 8:47 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-12-16 11:18 bug#67848: 29.1; Fix usage of `setq-default' and add explanation Xiyue Deng 2023-12-16 11:26 ` Xiyue Deng 2023-12-23 9:00 ` Eli Zaretskii 2023-12-23 10:09 ` Xiyue Deng 2023-12-23 11:20 ` Eli Zaretskii 2023-12-24 7:00 ` Xiyue Deng 2023-12-24 8:47 ` Eli Zaretskii
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.