Created
January 19, 2017 22:40
-
-
Save SkySkimmer/8cf587f61df973a20cb70ba6d1bc19ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun help-what-about () | |
| "Returns nil if called in non help-mode derived buffer. | |
| Otherwise guesses what the help buffer is about. | |
| If it succeeds the guess is returned as a string. Otherwise returns nil. | |
| Heuristics: | |
| If the buffer starts with a known symbol (i.e. in `obarray') that's our result. | |
| This may return the wrong thing: imagine a mode where `t t' runs `foo', we will | |
| think `describe-key' is talking about `t' alone. | |
| If someone defines `Enabled' we will be similarly confused after `describe-mode', etc." | |
| (if (derived-mode-p 'help-mode) | |
| (let ((described-thing | |
| ;; (current-word t ...) protects us against things | |
| ;; like describe-char which start with spaces | |
| (save-excursion (progn (goto-char (point-min)) (current-word t nil))))) | |
| (if (or | |
| (intern-soft described-thing) | |
| ;; Special case since (intern-soft "nil") ==> nil | |
| (string-equal described-thing "nil")) | |
| described-thing | |
| nil)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment