Package: emacs;
Reported by: Ergus <spacibba <at> aol.com>
Date: Sun, 30 May 2021 20:27:01 UTC
Severity: wishlist
Found in version 28.0.50
To reply to this bug, email your comments to 48752 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
View this report as an mbox folder, status mbox, maintainer mbox
bug-gnu-emacs <at> gnu.org
:bug#48752
; Package emacs
.
(Sun, 30 May 2021 20:27:01 GMT) Full text and rfc822 format available.Ergus <spacibba <at> aol.com>
:bug-gnu-emacs <at> gnu.org
.
(Sun, 30 May 2021 20:27:01 GMT) Full text and rfc822 format available.Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Ergus <spacibba <at> aol.com> To: bug-gnu-emacs <at> gnu.org Subject: 28.0.50; Feature request: Hook hide-ifdef into font-lock Date: Sun, 30 May 2021 22:26:06 +0200
The use of hide-ifdef is a bit outdated and it requires to manually call: `M-x hide-ifdefs` to update the buffer #if 0 <CODE> #endif M-x hide-ifdef-mode M-x hide-ifdef-toggle-shadowing does not shadows/hides the region <CODE>. It requires to explicitly call: M-x hide-ifdefs. Then if we change #if 0 -> #if 1; the shadow does not disappears/appears either until we call: M-x hide-ifdefs again. This part may be automatized. Calling hide-ifdefs every time is annoying and unneeded. Vim and most of other editors already do the re-fontification automatically. So we can take that behavior as a good starting point. Emacs is smart enough to recognize when the user modifies a cpp-macro. And multi-line code highlight is simple like /* */ does... I think font lock already has all the functionalities we need to add this feature in a more dynamic way. But some time ago (2008) there was a message in the mailing list advising not to implement hide-ifdef with font-lock due to performance concerns... but I am not sure if those are applicable still today. In GNU Emacs 28.0.50 (build 28, x86_64-pc-linux-gnu, GTK+ Version 3.24.29, cairo version 1.17.4) of 2021-05-29 built on Ergus Repository revision: e3fc16fd71a46990503a71b11a2ad592e99d9edb Repository branch: master System Description: Arch Linux Configured using: 'configure --prefix=/home/ergo/.local/ --with-mailutils --with-json --with-x-toolkit=gtk3 --with-xft --with-wide-int --with-modules --with-cairo --with-harfbuzz --with-native-compilation' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: global-auto-revert-mode: t xclip-mode: t yas-global-mode: t yas-minor-mode: t show-paren-mode: t repeat-mode: t flyspell-mode: t company-mode: t flycheck-mode: t counsel-mode: t ivy-mode: t electric-pair-mode: t composable-mark-mode: t composable-mode: t xterm-mouse-mode: t winner-mode: t save-place-mode: t which-key-mode: t override-global-mode: t delete-selection-mode: t savehist-mode: t global-display-fill-column-indicator-mode: t display-fill-column-indicator-mode: t global-display-line-numbers-mode: t display-line-numbers-mode: t eldoc-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t size-indication-mode: t column-number-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: /usr/share/emacs/site-lisp/cmake-mode hides /home/ergo/.emacs.d/elpa/cmake-mode-20210104.1831/cmake-mode /usr/share/emacs/site-lisp/notmuch-crypto hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch-crypto /usr/share/emacs/site-lisp/notmuch-compat hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch-compat /usr/share/emacs/site-lisp/notmuch-hello hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch-hello /usr/share/emacs/site-lisp/notmuch hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch /usr/share/emacs/site-lisp/notmuch-show hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch-show /usr/share/emacs/site-lisp/notmuch-maildir-fcc hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch-maildir-fcc /usr/share/emacs/site-lisp/coolj hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/coolj /usr/share/emacs/site-lisp/notmuch-draft hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch-draft /usr/share/emacs/site-lisp/notmuch-tree hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch-tree /usr/share/emacs/site-lisp/notmuch-parser hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch-parser /usr/share/emacs/site-lisp/notmuch-lib hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch-lib /usr/share/emacs/site-lisp/notmuch-mua hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch-mua /usr/share/emacs/site-lisp/notmuch-message hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch-message /usr/share/emacs/site-lisp/notmuch-address hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch-address /usr/share/emacs/site-lisp/notmuch-wash hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch-wash /usr/share/emacs/site-lisp/notmuch-tag hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch-tag /usr/share/emacs/site-lisp/notmuch-print hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch-print /usr/share/emacs/site-lisp/notmuch-query hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch-query /usr/share/emacs/site-lisp/notmuch-jump hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch-jump /usr/share/emacs/site-lisp/notmuch-company hides /home/ergo/.emacs.d/elpa/notmuch-20210515.1210/notmuch-company /home/ergo/.emacs.d/elpa/transient-20210525.1141/transient hides /home/ergo/.local/share/emacs/28.0.50/lisp/transient Features: (shadow sort notmuch-company notmuch-lib notmuch-version notmuch-compat mm-view mml-smime smime dig mailcap mail-extr emacsbug message rmc puny rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail rmail-loaddefs auth-source password-cache time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils autorevert filenotify xclip yasnippet-snippets yasnippet thingatpt amx comp comp-cstr warnings s paren repeat flyspell-correct-ivy flyspell-correct flyspell ispell company-keywords company-gtags company-dabbrev-code company-dabbrev company-files company-semantic company-template company-capf company flycheck json map find-func subr-x dash counsel xdg xref project dired-x dired dired-loaddefs compile text-property-search comint ansi-color swiper ivy-avy avy ivy flx ivy-faces ivy-overlay colir color pcase term/tmux term/xterm xterm jka-compr elec-pair init composable composable-mark xt-mouse simple-16-theme winner ring saveplace diminish edmacro kmacro which-key advice configmail cl-extra help-mode use-package use-package-ensure use-package-delight use-package-diminish use-package-bind-key bind-key use-package-core disp-table delsel savehist easy-mmode display-fill-column-indicator display-line-numbers info ede/auto eieio-base cl-seq seq eieio byte-opt bytecomp byte-compile cconv eieio-core cl-macs gv eieio-loaddefs cl-loaddefs cl-lib tex-site rx slime-autoloads early-init iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type 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 elisp-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 cl-generic 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 charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty make-network-process native-compile emacs) Memory information: ((conses 16 255105 10285) (symbols 48 18525 1) (strings 32 58700 7082) (string-bytes 1 2146750) (vectors 16 29784) (vector-slots 8 590763 10019) (floats 8 189 1037) (intervals 56 1022 0) (buffers 992 11))
bug-gnu-emacs <at> gnu.org
:bug#48752
; Package emacs
.
(Mon, 31 May 2021 12:02:01 GMT) Full text and rfc822 format available.Message #8 received at 48752 <at> debbugs.gnu.org (full text, mbox):
From: Eli Zaretskii <eliz <at> gnu.org> To: Ergus <spacibba <at> aol.com> Cc: 48752 <at> debbugs.gnu.org Subject: Re: bug#48752: 28.0.50; Feature request: Hook hide-ifdef into font-lock Date: Mon, 31 May 2021 15:01:42 +0300
> Date: Sun, 30 May 2021 22:26:06 +0200 > From: Ergus via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org> > > The use of hide-ifdef is a bit outdated and it requires to manually > call: `M-x hide-ifdefs` to update the buffer > > #if 0 > <CODE> > #endif > > M-x hide-ifdef-mode > M-x hide-ifdef-toggle-shadowing > > does not shadows/hides the region <CODE>. > > It requires to explicitly call: M-x hide-ifdefs. Did you try customizing hide-ifdef-initially to a non-nil value? > Then if we change #if 0 -> #if 1; > > the shadow does not disappears/appears either until we call: M-x > hide-ifdefs again. > > This part may be automatized. Calling hide-ifdefs every time is annoying > and unneeded. Vim and most of other editors already do the > re-fontification automatically. So we can take that behavior as a good > starting point. As mentioned on emacs-devel, how exactly to automate this should be carefully thought-out, because blindly using the JIT font-lock mechanism will cause code blocks to appear and disappear several time as long as the user types the preprocessor directive. It sounds like a no-brainer for a simple "#if 0" (which btw is rarely if ever used in real-life production code), but think about typing something like this: #if (defined __has_attribute \ && (!defined __clang_minor__ \ || 3 < __clang_major__ + (5 <= __clang_minor__))) (This is a real-life example from our conf_post.h, and there are a lot like it all over our code.) Depending on how each of the symbols are defined, the block under this could appear and disappear several times until you end typing. I'm quite sure we want to avoid this annoying effect as much as possible.
bug-gnu-emacs <at> gnu.org
:bug#48752
; Package emacs
.
(Mon, 31 May 2021 14:31:02 GMT) Full text and rfc822 format available.Message #11 received at 48752 <at> debbugs.gnu.org (full text, mbox):
From: Ergus <spacibba <at> aol.com> To: Eli Zaretskii <eliz <at> gnu.org> Cc: 48752 <at> debbugs.gnu.org Subject: Re: bug#48752: 28.0.50; Feature request: Hook hide-ifdef into font-lock Date: Mon, 31 May 2021 16:29:59 +0200
On Mon, May 31, 2021 at 03:01:42PM +0300, Eli Zaretskii wrote: >> Date: Sun, 30 May 2021 22:26:06 +0200 >> From: Ergus via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org> >> >> The use of hide-ifdef is a bit outdated and it requires to manually >> call: `M-x hide-ifdefs` to update the buffer >> >> #if 0 >> <CODE> >> #endif >> >> M-x hide-ifdef-mode >> M-x hide-ifdef-toggle-shadowing >> >> does not shadows/hides the region <CODE>. >> >> It requires to explicitly call: M-x hide-ifdefs. > >Did you try customizing hide-ifdef-initially to a non-nil value? > >> Then if we change #if 0 -> #if 1; >> >> the shadow does not disappears/appears either until we call: M-x >> hide-ifdefs again. >> >> This part may be automatized. Calling hide-ifdefs every time is annoying >> and unneeded. Vim and most of other editors already do the >> re-fontification automatically. So we can take that behavior as a good >> starting point. > >As mentioned on emacs-devel, how exactly to automate this should be >carefully thought-out, because blindly using the JIT font-lock >mechanism will cause code blocks to appear and disappear several time >as long as the user types the preprocessor directive. It sounds like >a no-brainer for a simple "#if 0" (which btw is rarely if ever used in >real-life production code), but think about typing something like >this: > > #if (defined __has_attribute \ > && (!defined __clang_minor__ \ > || 3 < __clang_major__ + (5 <= __clang_minor__))) > >(This is a real-life example from our conf_post.h, and there are a lot >like it all over our code.) Depending on how each of the symbols are >defined, the block under this could appear and disappear several times >until you end typing. I'm quite sure we want to avoid this annoying >effect as much as possible. Hi Eli: I understand that emacs tries to do something smarter than what vim and the other editors do, but this is limiting the basic trivial use case. I don;t actually think many people are using the hide-ifdef package... specially not new users. In the general case I understand that the block under this could appear and disappear, but that will be also a feedback for the user to know if the region will be enabled or not. For example in the case we have #if #else #endif That may be also very useful to know which branch will be compiled. I don't intend to get something very complex here, but at least the most basic highlight with trivial symbols may work. We use emacs to develop code, so, our code is not really production most of the time. And the #if 0 is very common in many code I have seen around. While the /* <CODE> // */ Approach I use is not common at all.
bug-gnu-emacs <at> gnu.org
:bug#48752
; Package emacs
.
(Mon, 31 May 2021 15:45:02 GMT) Full text and rfc822 format available.Message #14 received at 48752 <at> debbugs.gnu.org (full text, mbox):
From: Stefan Monnier <monnier <at> iro.umontreal.ca> To: Eli Zaretskii <eliz <at> gnu.org> Cc: 48752 <at> debbugs.gnu.org, Ergus <spacibba <at> aol.com> Subject: Re: bug#48752: 28.0.50; Feature request: Hook hide-ifdef into font-lock Date: Mon, 31 May 2021 11:44:01 -0400
> As mentioned on emacs-devel, how exactly to automate this should be > carefully thought-out, because blindly using the JIT font-lock > mechanism will cause code blocks to appear and disappear several time > as long as the user types the preprocessor directive. When the code is actually made invisible the appear/disappear could be quite annoying, indeed, but I think Ergus is mostly concerned about the case where `hide-ifdef-shadow` is activated, where it would make sense to make it behave like comments and strings, I think. Stefan
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.