Function: electric-helpify
electric-helpify is an autoloaded and byte-compiled function defined
in ehelp.el.gz.
Signature
(electric-helpify FUN &optional NAME)
Source Code
;; Defined in /usr/src/emacs/lisp/ehelp.el.gz
;;;###autoload
(defun electric-helpify (fun &optional name)
(let ((name (or name "*Help*")))
(if (save-window-excursion
;; kludge-o-rama
(let* ((p (symbol-function 'help-print-return-message))
(b (get-buffer name))
(m (buffer-modified-p b)))
(and b (not (get-buffer-window b))
(setq b nil))
(unwind-protect
(progn
(message "%s..." (capitalize (symbol-name fun)))
;; with-output-to-temp-buffer marks the buffer as unmodified.
;; kludging excessively and relying on that as some sort
;; of indication leads to the following abomination...
;;>> This would be doable without such icky kludges if either
;;>> (a) there were a function to read the interactive
;;>> args for a command and return a list of those args.
;;>> (To which one would then just apply the command)
;;>> (The only problem with this is that interactive-p
;;>> would break, but that is such a misfeature in
;;>> any case that I don't care)
;;>> It is easy to do this for emacs-lisp functions;
;;>> the only problem is getting the interactive spec
;;>> for subrs
;;>> (b) there were a function which returned a
;;>> modification-tick for a buffer. One could tell
;;>> whether a buffer had changed by whether the
;;>> modification-tick were different.
;;>> (Presumably there would have to be a way to either
;;>> restore the tick to some previous value, or to
;;>> suspend updating of the tick in order to allow
;;>> things like momentary-string-display)
(and b
(with-current-buffer b
(set-buffer-modified-p t)))
(fset 'help-print-return-message 'ignore)
(call-interactively fun)
(and (get-buffer name)
(get-buffer-window (get-buffer name))
(or (not b)
(not (eq b (get-buffer name)))
(not (buffer-modified-p b)))))
(fset 'help-print-return-message p)
(and b (buffer-name b)
(with-current-buffer b
(set-buffer-modified-p m))))))
(with-electric-help 'ignore name t))))