* bug#45560: 27.1; add-change-log-entry erroneously removes "const" from function name @ 2020-12-30 23:11 Tom Tromey 2020-12-31 5:09 ` Lars Ingebrigtsen 0 siblings, 1 reply; 5+ messages in thread From: Tom Tromey @ 2020-12-30 23:11 UTC (permalink / raw) To: 45560 Put this into a .c file: void const_ref () { } Now, put point inside the braces and M-x add-change-log-entry. For me the resulting ChangeLog looks like: 2020-12-30 Tom Tromey <tom@tromey.com> * q.c (_ref): Note that the "const" was removed. However, it should not be removed here, as it is part of the function's name. In GNU Emacs 27.1 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.21, cairo version 1.16.0) of 2020-08-20 built on buildvm-x86-24.iad2.fedoraproject.org Windowing system distributor 'Fedora Project', version 11.0.12010000 System Description: Fedora 32 (Workstation Edition) Recent messages: Saving file /tmp/q.c... Wrote /tmp/q.c Quit C-c a runs the command tromey-add-change-log-entry Undo [3 times] Redo [2 times] C-x C-g is undefined Quit Scanning for dabbrevs...done user-error: No dynamic expansion for ‘add-changelo’ found Configured using: 'configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-png --with-rsvg --with-tiff --with-xft --with-xpm --with-x-toolkit=gtk3 --with-gpm=no --with-xwidgets --with-modules --with-harfbuzz --with-cairo --with-json build_alias=x86_64-redhat-linux-gnu host_alias=x86_64-redhat-linux-gnu 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' LDFLAGS=-Wl,-z,relro PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig' Configured features: XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS LIBSYSTEMD JSON PDUMPER GMP Important settings: value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: Change Log Minor modes in effect: flyspell-mode: t shell-dirtrack-mode: t which-function-mode: t erc-services-mode: t erc-networks-mode: t savehist-mode: t tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t column-number-mode: t line-number-mode: t auto-fill-function: do-auto-fill transient-mark-mode: t Load-path shadows: /home/tromey/.emacs.d/elpa/bubbles-0.5/bubbles hides /usr/share/emacs/27.1/lisp/play/bubbles Features: (shadow mail-hist emacsbug flow-fill tcl shr-color mm-archive sh-script smie executable rect copyright dabbrev goto-addr ggtags hippie-exp etags fileloop generator xref project bug-reference smerge-mode diff cc-mode cc-fonts cc-guess cc-menus cc-cmds term/xterm xterm apropos mule-diag descr-text sort smiley gnus-cite mail-extr gnus-bcklg gnus-async qp gnus-ml disp-table gnus-topic nndraft nnmh nnfolder utf-7 gnutls network-stream nsm gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime dig nntp gnus-cache gnus-sum url url-proxy url-privacy url-expand url-methods url-history mailcap shr url-cookie url-domsuf url-util svg xml dom gnus-group gnus-undo smtpmail sendmail gnus-start gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo gnus-spec gnus-int gnus-range message rmc puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader gnus-win gnus nnheader gnus-util rmail rmail-loaddefs rfc2047 rfc2045 ietf-drums text-property-search mail-utils mm-util mail-prsvr two-column iso-transl help-fns radix-tree log-view pcvs-util vc-mtn vc-hg cl-extra help-mode vc-git diff-mode vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs misearch multi-isearch add-log flyspell ispell diminish projectile ibuf-macs pcase edmacro kmacro grep compile ibuf-ext ibuffer ibuffer-loaddefs dash appt diary-lib diary-loaddefs cal-menu calendar cal-loaddefs tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat shell pcomplete parse-time iso8601 time-date ls-lisp which-func imenu minimap autorevert filenotify cus-start cus-load erc-track erc-match erc-services erc-networks erc-hl-nicks easy-mmode color erc-button erc-fill erc-stamp wid-edit erc-goodies erc erc-backend erc-compat format-spec thingatpt pp erc-loaddefs warnings advice vc-dir ewoc vc vc-dispatcher cc-styles cc-align cc-engine cc-vars cc-defs ange-ftp comint ansi-color ring server savehist finder-inf gdb-shell-autoloads lisppaste-autoloads pydoc-info-autoloads info-look info cl weblogger-autoloads package easymenu browse-url url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib 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 timer select scroll-bar mouse jit-lock font-lock syntax facemenu 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 loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify dynamic-setting system-font-setting font-render-setting xwidget-internal cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 1344143 98632) (symbols 48 71080 17) (strings 32 190276 19842) (string-bytes 1 6368664) (vectors 16 83075) (vector-slots 8 2440137 207780) (floats 8 448 669) (intervals 56 185659 164) (buffers 1000 464)) ^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#45560: 27.1; add-change-log-entry erroneously removes "const" from function name 2020-12-30 23:11 bug#45560: 27.1; add-change-log-entry erroneously removes "const" from function name Tom Tromey @ 2020-12-31 5:09 ` Lars Ingebrigtsen 2021-01-01 16:20 ` Alan Mackenzie 0 siblings, 1 reply; 5+ messages in thread From: Lars Ingebrigtsen @ 2020-12-31 5:09 UTC (permalink / raw) To: Tom Tromey; +Cc: Alan Mackenzie, 45560 Tom Tromey <tom@tromey.com> writes: > Put this into a .c file: > > void > const_ref () > { > } > > Now, put point inside the braces and M-x add-change-log-entry. > > For me the resulting ChangeLog looks like: > > 2020-12-30 Tom Tromey <tom@tromey.com> > > * q.c (_ref): Debugging this, it looks like this is down to (c-defun-name-1) returning "_ref" if called in the const_ref function, so I've added Alan to the CCs. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#45560: 27.1; add-change-log-entry erroneously removes "const" from function name 2020-12-31 5:09 ` Lars Ingebrigtsen @ 2021-01-01 16:20 ` Alan Mackenzie 2021-01-02 5:42 ` Lars Ingebrigtsen 0 siblings, 1 reply; 5+ messages in thread From: Alan Mackenzie @ 2021-01-01 16:20 UTC (permalink / raw) To: Lars Ingebrigtsen, Tom Tromey; +Cc: acm, 45560 Hello, Lars and Tom On Thu, Dec 31, 2020 at 06:09:21 +0100, Lars Ingebrigtsen wrote: > Tom Tromey <tom@tromey.com> writes: > > Put this into a .c file: > > > > void > > const_ref () > > { > > } > > > > Now, put point inside the braces and M-x add-change-log-entry. > > > > For me the resulting ChangeLog looks like: > > > > 2020-12-30 Tom Tromey <tom@tromey.com> > > > > * q.c (_ref): > Debugging this, it looks like this is down to > (c-defun-name-1) > returning "_ref" if called in the const_ref function, so I've added Alan > to the CCs. Yes, there was a regular expression recognising "const" where it shouldn't have. It was a regexp with many discordant, conflicting requirements, so I had to "split it in two" to get it working properly. Please try the following patch out, which shouldn't be at all controversial, and let me know whether it fixes everything. Thanks! diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 7444f0f805..60e85fc085 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -9021,14 +9021,15 @@ c-forward-declarator (c-forward-noise-clause)) ((and (looking-at c-type-decl-prefix-key) (if (and (c-major-mode-is 'c++-mode) - (match-beginning 3)) + (match-beginning 4)) ; Was 3 - 2021-01-01 ;; If the third submatch matches in C++ then ;; we're looking at an identifier that's a ;; prefix only if it specifies a member pointer. (progn (setq id-start (point)) (c-forward-name) - (if (looking-at "\\(::\\)") + (if (save-match-data + (looking-at "\\(::\\)")) ;; We only check for a trailing "::" and ;; let the "*" that should follow be ;; matched in the next round. @@ -9038,13 +9039,15 @@ c-forward-declarator (setq got-identifier t) nil)) t)) - (if (looking-at c-type-decl-operator-prefix-key) + (if (save-match-data + (looking-at c-type-decl-operator-prefix-key)) (setq decorated t)) (if (eq (char-after) ?\() (progn (setq paren-depth (1+ paren-depth)) (forward-char)) - (goto-char (match-end 1))) + (goto-char (or (match-end 1) + (match-end 2)))) (c-forward-syntactic-ws) t))) @@ -9721,14 +9724,15 @@ c-forward-decl-or-cast-1 (setq after-paren-pos (point)))) (while (and (looking-at c-type-decl-prefix-key) (if (and (c-major-mode-is 'c++-mode) - (match-beginning 3)) + (match-beginning 4)) ;; If the third submatch matches in C++ then ;; we're looking at an identifier that's a ;; prefix only if it specifies a member pointer. (when (progn (setq pos (point)) (setq got-identifier (c-forward-name))) (setq name-start pos) - (if (looking-at "\\(::\\)") + (if (save-match-data + (looking-at "\\(::\\)")) ;; We only check for a trailing "::" and ;; let the "*" that should follow be ;; matched in the next round. @@ -9749,7 +9753,8 @@ c-forward-decl-or-cast-1 (when (save-match-data (looking-at c-type-decl-operator-prefix-key)) (setq got-function-name-prefix t)) - (goto-char (match-end 1))) + (goto-char (or (match-end 1) + (match-end 2)))) (c-forward-syntactic-ws))) (setq got-parens (> paren-depth 0)) diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index c3cd81e1e8..9577f55e87 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el @@ -3433,41 +3433,47 @@ c-populate-syntax-table t (c-make-bare-char-alt (c-lang-const c-block-prefix-disallowed-chars) t)) (c-lang-defvar c-block-prefix-charset (c-lang-const c-block-prefix-charset)) -(c-lang-defconst c-type-decl-prefix-key - "Regexp matching any declarator operator that might precede the -identifier in a declaration, e.g. the \"*\" in \"char *argv\". This -regexp should match \"(\" if parentheses are valid in declarators. -The end of the first submatch is taken as the end of the operator. -Identifier syntax is in effect when this is matched (see -`c-identifier-syntax-table')." +(c-lang-defconst c-type-decl-prefix-keywords-key + ;; Regexp matching any keyword operator that might precede the identifier in + ;; a declaration, e.g. "const" or nil. It doesn't test there is no "_" + ;; following the keyword. t (if (or (c-lang-const c-type-modifier-kwds) (c-lang-const c-modifier-kwds)) - (concat + (concat (regexp-opt (c--delete-duplicates (append (c-lang-const c-type-modifier-kwds) (c-lang-const c-modifier-kwds)) :test 'string-equal) t) - "\\>") - ;; Default to a regexp that never matches. - regexp-unmatchable) + "\\>"))) + +(c-lang-defconst c-type-decl-prefix-key + "Regexp matching any declarator operator that might precede the +identifier in a declaration, e.g. the \"*\" in \"char *argv\". This +regexp should match \"(\" if parentheses are valid in declarators. +The operator found is either the first submatch (if it is not a +keyword) or the second submatch (if it is)." + t (if (c-lang-const c-type-decl-prefix-keywords-key) + (concat "\\(\\`a\\`\\)\\|" ; 1 - will never match. + (c-lang-const c-type-decl-prefix-keywords-key) ; 2 + "\\([^_]\\|$\\)") ; 3 + regexp-unmatchable) ;; Default to a regexp that never matches. ;; Check that there's no "=" afterwards to avoid matching tokens ;; like "*=". - (c objc) (concat "\\(" + (c objc) (concat "\\(" ; 1 "[*(]" - "\\|" - (c-lang-const c-type-decl-prefix-key) - "\\)" - "\\([^=]\\|$\\)") - c++ (concat "\\(" + "\\)\\|" + (c-lang-const c-type-decl-prefix-keywords-key) ; 2 + "\\([^=_]\\|$\\)") ; 3 + c++ (concat "\\(" ; 1 "&&" "\\|" "\\.\\.\\." "\\|" "[*(&~]" + "\\)\\|\\(" ; 2 + (c-lang-const c-type-decl-prefix-keywords-key) ; 3 "\\|" - (c-lang-const c-type-decl-prefix-key) - "\\|" - (concat "\\(" ; 3 + (concat "\\(" ; 4 ;; If this matches there's special treatment in ;; `c-font-lock-declarators' and ;; `c-font-lock-declarations' that check for a @@ -3475,8 +3481,9 @@ c-populate-syntax-table (c-lang-const c-identifier-start) "\\)") "\\)" - "\\([^=]\\|$\\)") + "\\([^=_]\\|$\\)") ; 5 pike "\\(\\*\\)\\([^=]\\|$\\)") + (c-lang-defvar c-type-decl-prefix-key (c-lang-const c-type-decl-prefix-key) 'dont-doc) > -- > (domestic pets only, the antidote for overdose, milk.) > bloggy blog: http://lars.ingebrigtsen.no -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#45560: 27.1; add-change-log-entry erroneously removes "const" from function name 2021-01-01 16:20 ` Alan Mackenzie @ 2021-01-02 5:42 ` Lars Ingebrigtsen 2021-02-02 20:42 ` Alan Mackenzie 0 siblings, 1 reply; 5+ messages in thread From: Lars Ingebrigtsen @ 2021-01-02 5:42 UTC (permalink / raw) To: Alan Mackenzie; +Cc: Tom Tromey, 45560 Alan Mackenzie <acm@muc.de> writes: > Please try the following patch out, which shouldn't be at all > controversial, and let me know whether it fixes everything. Thanks! Yup; your patch fixes the test case here, too. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#45560: 27.1; add-change-log-entry erroneously removes "const" from function name 2021-01-02 5:42 ` Lars Ingebrigtsen @ 2021-02-02 20:42 ` Alan Mackenzie 0 siblings, 0 replies; 5+ messages in thread From: Alan Mackenzie @ 2021-02-02 20:42 UTC (permalink / raw) To: Lars Ingebrigtsen, Tom Tromey; +Cc: 45560-done Hello, Lars and Tom. On Sat, Jan 02, 2021 at 06:42:07 +0100, Lars Ingebrigtsen wrote: > Alan Mackenzie <acm@muc.de> writes: > > Please try the following patch out, which shouldn't be at all > > controversial, and let me know whether it fixes everything. Thanks! > Yup; your patch fixes the test case here, too. Thanks! I've committed the patch, and I'm closing the bug with this post. > -- > (domestic pets only, the antidote for overdose, milk.) > bloggy blog: http://lars.ingebrigtsen.no -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-02-02 20:42 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-12-30 23:11 bug#45560: 27.1; add-change-log-entry erroneously removes "const" from function name Tom Tromey 2020-12-31 5:09 ` Lars Ingebrigtsen 2021-01-01 16:20 ` Alan Mackenzie 2021-01-02 5:42 ` Lars Ingebrigtsen 2021-02-02 20:42 ` Alan Mackenzie
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).