unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Bug #29083: Is it OK to add a new function to the emacs-26 branch?
@ 2017-11-01 11:21 Alan Mackenzie
  2017-11-01 13:27 ` Compro Prasad
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Alan Mackenzie @ 2017-11-01 11:21 UTC (permalink / raw)
  To: emacs-devel

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).



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-11-03 17:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-01 11:21 Bug #29083: Is it OK to add a new function to the emacs-26 branch? Alan Mackenzie
2017-11-01 13:27 ` Compro Prasad
2017-11-01 17:05 ` John Wiegley
2017-11-01 19:43   ` Eli Zaretskii
2017-11-01 19:56     ` John Wiegley
2017-11-02 19:24       ` Alan Mackenzie
2017-11-03 15:35 ` Stefan Monnier
2017-11-03 16:22   ` Alan Mackenzie
2017-11-03 17:04     ` Stefan Monnier

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).