Re: finding the overriding body for an overloadable function.
Stephen Leake <[email protected]> Sat, 15 Aug 2015 13:19:04 -0500
| Newsgroups | gmane.emacs.semantic |
|---|---|
| Message-ID | <[email protected]> |
Stephen Leake <[email protected]> writes: > I think for both *Help* and xref-find-definitions it would be ok to show > the definition for the current buffer (including when that's the > default); a single fetch-overload is sufficient for that. Attached is a patch that shows the current override in *Help*. It depends on a change I just commited to Emacs master. I left mode-local-augment-function-help alone; it appears to be intended for a different use. Next I'll do something similar for xref. -- -- Stephe ------------------------------------------------------------------------------ _______________________________________________ cedet-semantic mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/cedet-semantic
describe-mode-local.diff
(text/x-patch, 3.1 KB)
diff --git a/lisp/cedet/mode-local.el b/lisp/cedet/mode-local.el index 7c75e3f..6c2e894 100644 --- a/lisp/cedet/mode-local.el +++ b/lisp/cedet/mode-local.el @@ -1,6 +1,6 @@ ;;; mode-local.el --- Support for mode local facilities ;; -;; Copyright (C) 2004-2005, 2007-2013 Free Software Foundation, Inc. +;; Copyright (C) 2004-2005, 2007-2013, 2015 Free Software Foundation, Inc. ;; ;; Author: David Ponce <[email protected]> ;; Maintainer: David Ponce <[email protected]> @@ -597,16 +597,18 @@ PROMPT, INITIAL, HIST, and DEFAULT are the same as for `completing-read'." ;; (defun overload-docstring-extension (overload) "Return the doc string that augments the description of OVERLOAD." - (let ((doc "\n\This function can be overloaded\ - with `define-mode-local-override'.") + (let ((doc (substitute-command-keys "\n\This function can be overloaded\ + with `define-mode-local-override'.")) (sym (overload-obsoleted-by overload))) (when sym - (setq doc (format "%s\nIt has made the overload `%s' obsolete since %s." - doc sym (get sym 'overload-obsoleted-since)))) + (setq doc (substitute-command-keys + (format "%s\nIt has made the overload `%s' obsolete since %s." + doc sym (get sym 'overload-obsoleted-since))))) (setq sym (overload-that-obsolete overload)) (when sym - (setq doc (format "%s\nThis overload is obsolete since %s;\nUse `%s' instead." - doc (get overload 'overload-obsoleted-since) sym))) + (setq doc (substitute-command-keys + (format "%s\nThis overload is obsolete since %s;\nUse `%s' instead." + doc (get overload 'overload-obsoleted-since) sym)))) doc)) (defun mode-local-augment-function-help (symbol) @@ -625,6 +627,30 @@ SYMBOL is a function that can be overridden." ;; LIST ALL LOADED OVERRIDES FOR SYMBOL HERE ))) +(defun describe-mode-local-overload (symbol) + "For `help-fns-describe-function-functions'; add overloads for SYMBOL." + (when (get symbol 'mode-local-overload) + (let ((default (or (intern-soft (format "%s-default" (symbol-name symbol))) + 'symbol)) + (override (and + (boundp 'describe-function-orig-buffer) ;; added in Emacs 25 + describe-function-orig-buffer + (with-current-buffer describe-function-orig-buffer + (fetch-overload symbol))))) + (insert (overload-docstring-extension symbol) "\n\n") + (insert (substitute-command-keys (format "default function: `%s'\n" default))) + (when (and (boundp 'describe-function-orig-buffer) ;; added in Emacs 25 + describe-function-orig-buffer) + (if override + (insert (substitute-command-keys + (format "\noverride in buffer '%s': `%s'\n" + describe-function-orig-buffer override))) + (insert (substitute-command-keys (format "\nno override in buffer '%s'\n" + describe-function-orig-buffer))))) + ))) + +(add-hook 'help-fns-describe-function-functions 'describe-mode-local-overload) + ;; Help for mode-local bindings. (defun mode-local-print-binding (symbol) "Print the SYMBOL binding."