emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug #29083: Is it OK to add a new function to the emacs-26 branch?


From: Alan Mackenzie
Subject: Bug #29083: Is it OK to add a new function to the emacs-26 branch?
Date: Wed, 1 Nov 2017 11:21:44 +0000
User-agent: Mutt/1.7.2 (2016-11-26)

Hello, Emacs.

This bug said that doing M-x c-defun-name failed to display the current
function name.  This is true; c-defun-name merely returns that name to
the calling lisp program, and should never have been interactive.  It's
not going to be interactive for much longer.

However, the OP has requested that a function which actually displays
this name be put into CC Mode.  Would it still be OK to do this on the
emacs-26 branch, or is this branch now closed for such things?

The function I'm proposing adding to cc-cmds.el is "harmless", having no
interaction with the rest of CC Mode.  It would look like this:

     (defun c-display-defun-name (&optional arg)
       "Display the name of the current CC mode defun and the position in it.
     With a prefix arg, push the name onto the kill ring too."
       (interactive "P")
       (save-restriction
         (widen)
         (c-save-buffer-state ((name (c-defun-name))
                               (limits (c-declaration-limits t))
                               (point-bol (c-point 'bol)))
           (when name
             (message "%s.  Line %s/%s." name
                      (1+ (count-lines (car limits) point-bol))
                      (count-lines (car limits) (cdr limits)))
             (if arg (kill-new name))
             (sit-for 3 t)))))
     (put 'c-display-defun-name 'isearch-scroll t)))

It has been well tested by me personally.

I haven't yet decided whether or not it should get a major mode key
binding, say C-c C-m.

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]