* patch to fill overlong lines in `describe-key'
@ 2008-01-03 19:59 Drew Adams
0 siblings, 0 replies; 3+ messages in thread
From: Drew Adams @ 2008-01-03 19:59 UTC (permalink / raw)
To: Emacs-Devel
[-- Attachment #1: Type: text/plain, Size: 1487 bytes --]
The first few lines output by `describe-key' can be overly long. Example:
<menu-bar> <operate> <icicles> <icicle-candidate-set-dired-marked-save-more>
runs the command icicle-candidate-set-dired-marked-save-more
which is an interactive compiled Lisp function in `icicles-cmd.el'.
It is bound to C-), <menu-bar> <operate> <icicles>
<icicle-candidate-set-dired-marked-save-more>.
(icicle-candidate-set-dired-marked-save-more &optional ARG)
The code currently attempts to deal with this by hard-coding a newline
before "which is", but that doesn't cut the mustard.
The same problem can occur in some subsequent lines, because of embedded
calls to `describe-function-1'.
The attached patches fill the text of such occurrences as separate
paragraphs. Example:
<menu-bar> <operate> <icicles>
<icicle-candidate-set-dired-marked-save-more> runs the command
icicle-candidate-set-dired-marked-save-more, which is an interactive
compiled Lisp function in `icicles-cmd.el'.
It is bound to C-), <menu-bar> <operate> <icicles>
<icicle-candidate-set-dired-marked-save-more>.
(icicle-candidate-set-dired-marked-save-more &optional ARG)
I also added a comma (,) before "which" in several places where it
introduces an independent clause (see above for an example).
I tested a similar patch against the 22.1 release code. Please try this out
with the latest CVS code. There are several different cases to try,
including mouse-2 remapping. Let me know if you find a case where it doesn't
DTRT.
[-- Attachment #2: help-2008-01-02.patch --]
[-- Type: application/octet-stream, Size: 5842 bytes --]
diff -c help-CVS-2008-01-02.el help-patched-2008-01-02.el
*** help-CVS-2008-01-02.el Wed Jan 2 15:19:54 2008
--- help-patched-2008-01-02.el Thu Jan 3 10:55:58 2008
***************
*** 657,691 ****
(cursor-in-echo-area t)
saved-yank-menu)
(unwind-protect
! (let (key)
! ;; If yank-menu is empty, populate it temporarily, so that
! ;; "Select and Paste" menu can generate a complete event.
! (when (null (cdr yank-menu))
! (setq saved-yank-menu (copy-sequence yank-menu))
! (menu-bar-update-yank-menu "(any string)" nil))
! (setq key (read-key-sequence "Describe key (or click or menu item): "))
! (list
! key
! (prefix-numeric-value current-prefix-arg)
! ;; If KEY is a down-event, read and include the
! ;; corresponding up-event. Note that there are also
! ;; down-events on scroll bars and mode lines: the actual
! ;; event then is in the second element of the vector.
! (and (vectorp key)
! (let ((last-idx (1- (length key))))
! (and (eventp (aref key last-idx))
! (memq 'down (event-modifiers (aref key last-idx)))))
! (or (and (eventp (aref key 0))
! (memq 'down (event-modifiers (aref key 0)))
! ;; However, for the C-down-mouse-2 popup
! ;; menu, there is no subsequent up-event. In
! ;; this case, the up-event is the next
! ;; element in the supplied vector.
! (= (length key) 1))
! (and (> (length key) 1)
! (eventp (aref key 1))
! (memq 'down (event-modifiers (aref key 1)))))
! (read-event))))
;; Put yank-menu back as it was, if we changed it.
(when saved-yank-menu
(setq yank-menu (copy-sequence saved-yank-menu))
--- 657,691 ----
(cursor-in-echo-area t)
saved-yank-menu)
(unwind-protect
! (let (key)
! ;; If yank-menu is empty, populate it temporarily, so that
! ;; "Select and Paste" menu can generate a complete event.
! (when (null (cdr yank-menu))
! (setq saved-yank-menu (copy-sequence yank-menu))
! (menu-bar-update-yank-menu "(any string)" nil))
! (setq key (read-key-sequence "Describe key (or click or menu item): "))
! (list
! key
! (prefix-numeric-value current-prefix-arg)
! ;; If KEY is a down-event, read and include the
! ;; corresponding up-event. Note that there are also
! ;; down-events on scroll bars and mode lines: the actual
! ;; event then is in the second element of the vector.
! (and (vectorp key)
! (let ((last-idx (1- (length key))))
! (and (eventp (aref key last-idx))
! (memq 'down (event-modifiers (aref key last-idx)))))
! (or (and (eventp (aref key 0))
! (memq 'down (event-modifiers (aref key 0)))
! ;; However, for the C-down-mouse-2 popup
! ;; menu, there is no subsequent up-event. In
! ;; this case, the up-event is the next
! ;; element in the supplied vector.
! (= (length key) 1))
! (and (> (length key) 1)
! (eventp (aref key 1))
! (memq 'down (event-modifiers (aref key 1)))))
! (read-event))))
;; Put yank-menu back as it was, if we changed it.
(when saved-yank-menu
(setq yank-menu (copy-sequence saved-yank-menu))
***************
*** 745,752 ****
(with-help-window (help-buffer)
(princ (help-key-description key untranslated))
(princ (format "\
! %s runs the command %S
! which is "
mouse-msg defn))
(describe-function-1 defn)
(when up-event
--- 745,751 ----
(with-help-window (help-buffer)
(princ (help-key-description key untranslated))
(princ (format "\
! %s runs the command %S, which is "
mouse-msg defn))
(describe-function-1 defn)
(when up-event
***************
*** 757,780 ****
----------------- up-event %s----------------
! <%S>%s%s runs the command %S
! which is "
! (if mouse-1-tricky "(short click) " "")
! ev-type mouse-msg
! (if mouse-1-remapped
! " is remapped to <mouse-2>\nwhich" "")
! defn-up))
! (describe-function-1 defn-up))
! (unless (or (null defn-up-tricky)
! (integerp defn-up-tricky)
! (eq defn-up-tricky 'undefined))
! (princ (format "
----------------- up-event (long click) ----------------
Pressing <%S>%s for longer than %d milli-seconds
! runs the command %S
! which is "
ev-type mouse-msg
mouse-1-click-follows-link
defn-up-tricky))
--- 756,777 ----
----------------- up-event %s----------------
! <%S>%s%s runs the command %S, which is "
! (if mouse-1-tricky "(short click) " "")
! ev-type mouse-msg
! (if mouse-1-remapped
! " is remapped to <mouse-2>, which" "")
! defn-up))
! (describe-function-1 defn-up))
! (unless (or (null defn-up-tricky)
! (integerp defn-up-tricky)
! (eq defn-up-tricky 'undefined))
! (princ (format "
----------------- up-event (long click) ----------------
Pressing <%S>%s for longer than %d milli-seconds
! runs the command %S, which is "
ev-type mouse-msg
mouse-1-click-follows-link
defn-up-tricky))
[-- Attachment #3: help-fns-2007-10-19.patch --]
[-- Type: application/octet-stream, Size: 6743 bytes --]
*** help-fns-CVS-2007-10-19.el Fri Oct 19 10:38:10 2007
--- help-fns-patched-2007-10-19.el Fri Oct 19 11:39:10 2007
***************
*** 38,45 ****
;; Functions
;;;###autoload
! (defun describe-function (function)
! "Display the full documentation of FUNCTION (a symbol)."
(interactive
(let ((fn (function-called-at-point))
(enable-recursive-minibuffers t)
--- 38,48 ----
;; Functions
;;;###autoload
! (defun describe-function (function &optional commandp)
! "Display the full documentation of FUNCTION (a symbol).
! FUNCTION names an Emacs Lisp function, possibly a user command.
! With a prefix arg, candidates are commands (interactive functions).
! Returns the description that was displayed, as a string."
(interactive
(let ((fn (function-called-at-point))
(enable-recursive-minibuffers t)
***************
*** 47,58 ****
(setq val (completing-read (if fn
(format "Describe function (default %s): " fn)
"Describe function: ")
! obarray 'fboundp t nil nil
! (and fn (symbol-name fn))))
! (list (if (equal val "")
! fn (intern val)))))
(if (null function)
(message "You didn't specify a function")
(help-setup-xref (list #'describe-function function) (interactive-p))
(save-excursion
(with-output-to-temp-buffer (help-buffer)
--- 50,63 ----
(setq val (completing-read (if fn
(format "Describe function (default %s): " fn)
"Describe function: ")
! obarray (if current-prefix-arg 'commandp 'fboundp)
! t nil nil (and fn (symbol-name fn))))
! (list (if (equal val "") fn (intern val))
! current-prefix-arg)))
(if (null function)
(message "You didn't specify a function")
+ (unless (or (not commandp) (commandp function))
+ (error "Not a defined Emacs command (interactive function): `%s'" function))
(help-setup-xref (list #'describe-function function) (interactive-p))
(save-excursion
(with-output-to-temp-buffer (help-buffer)
***************
*** 66,71 ****
--- 71,92 ----
;; Return the text we displayed.
(buffer-string))))))
+ ;;;###autoload
+ (defun describe-command (function)
+ "Describe an Emacs command (interactive function).
+ Same as using a prefix argument with command `describe-function'."
+ (interactive
+ (let ((fn (function-called-at-point))
+ (enable-recursive-minibuffers t)
+ val)
+ (setq val (completing-read (if fn
+ (format "Describe command (default %s): " fn)
+ "Describe command: ")
+ obarray 'commandp t nil nil
+ (and fn (symbol-name fn))))
+ (list (if (equal val "") fn (intern val)))))
+ (describe-function function t))
+
(defun help-split-fundoc (docstring def)
"Split a function DOCSTRING into the actual doc and the usage info.
Return (USAGE . DOC) or nil if there's no usage info.
***************
*** 457,467 ****
0))
;;;###autoload
! (defun describe-variable (variable &optional buffer frame)
"Display the full documentation of VARIABLE (a symbol).
! Returns the documentation as a string, also.
If VARIABLE has a buffer-local value in BUFFER or FRAME
! \(default to the current buffer and current frame),
it is displayed along with the global value."
(interactive
(let ((v (variable-at-point))
--- 478,490 ----
0))
;;;###autoload
! (defun describe-variable (variable &optional buffer frame optionp)
"Display the full documentation of VARIABLE (a symbol).
! VARIABLE names an Emacs Lisp variable, possibly a user option.
! With a prefix argument, candidates are user variables (options) only.
! Returns the documentation as a string.
If VARIABLE has a buffer-local value in BUFFER or FRAME
! \(default to the current buffer and current frame), then
it is displayed along with the global value."
(interactive
(let ((v (variable-at-point))
***************
*** 472,488 ****
"Describe variable (default %s): " v)
"Describe variable: ")
obarray
! '(lambda (vv)
! (or (boundp vv)
! (get vv 'variable-documentation)))
t nil nil
(if (symbolp v) (symbol-name v))))
! (list (if (equal val "")
! v (intern val)))))
(unless (buffer-live-p buffer) (setq buffer (current-buffer)))
(unless (frame-live-p frame) (setq frame (selected-frame)))
(if (not (symbolp variable))
(message "You did not specify a variable")
(save-excursion
(let ((valvoid (not (with-current-buffer buffer (boundp variable))))
val val-start-pos locus)
--- 495,516 ----
"Describe variable (default %s): " v)
"Describe variable: ")
obarray
! (if current-prefix-arg
! (lambda (vv) (user-variable-p vv))
! (lambda (vv)
! (or (boundp vv) (get vv 'variable-documentation))))
t nil nil
(if (symbolp v) (symbol-name v))))
! (list (if (equal val "") v (intern val))
! nil
! nil
! current-prefix-arg)))
(unless (buffer-live-p buffer) (setq buffer (current-buffer)))
(unless (frame-live-p frame) (setq frame (selected-frame)))
(if (not (symbolp variable))
(message "You did not specify a variable")
+ (unless (or (not optionp) (user-variable-p variable))
+ (error "Not a defined Emacs user option: `%s'" variable))
(save-excursion
(let ((valvoid (not (with-current-buffer buffer (boundp variable))))
val val-start-pos locus)
***************
*** 662,667 ****
--- 690,713 ----
;; Return the text we displayed.
(buffer-string))))))))
+ ;;;###autoload
+ (defun describe-option (variable &optional buffer frame)
+ "Describe an Emacs user variable (option).
+ Same as using a prefix argument with command `describe-variable'."
+ (interactive
+ (let ((v (variable-at-point))
+ (enable-recursive-minibuffers t)
+ val)
+ (setq val (completing-read (if (symbolp v)
+ (format "Describe option (default %s): " v)
+ "Describe option: ")
+ obarray 'user-variable-p t nil nil
+ (if (symbolp v) (symbol-name v))))
+ (list (if (equal val "") v (intern val))
+ nil
+ nil
+ current-prefix-arg)))
+ (describe-variable variable buffer frame t))
;;;###autoload
(defun describe-syntax (&optional buffer)
Diff finished. Fri Oct 19 12:02:43 2007
[-- Attachment #4: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: patch to fill overlong lines in `describe-key'
@ 2008-02-12 6:18 Drew Adams
2008-02-12 7:11 ` Bastien
0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2008-02-12 6:18 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 403 bytes --]
I mistakenly sent the wrong patch for help-fns.el. I sent a patch that added
command `describe-option' and such - something unrelated. Attached are
updated patches wrt today's CVS.
And here's a change log entry:
2008-02-11 Drew Adams <drew.adams@oracle.com>
* help.el (describe-key): Joined some split lines to facilitate
filling.
* help-fns.el (describe-function-1): Fill text of overlong lines.
[-- Attachment #2: help-fns-2008-02-11.patch --]
[-- Type: application/octet-stream, Size: 3225 bytes --]
diff -c -w help-fns-CVS-2008-02-11.el help-fns-patched-2008-02-11.el
*** help-fns-CVS-2008-02-11.el Mon Feb 11 14:23:56 2008
--- help-fns-patched-2008-02-11.el Mon Feb 11 14:28:46 2008
***************
*** 269,275 ****
(symbol-function real-function)
function))
file-name string
! (beg (if (commandp def) "an interactive " "a ")))
(setq string
(cond ((or (stringp def) (vectorp def))
"a keyboard macro")
--- 269,276 ----
(symbol-function real-function)
function))
file-name string
! (beg (if (commandp def) "an interactive " "a "))
! (pt1 (with-current-buffer (help-buffer) (point))))
(setq string
(cond ((or (stringp def) (vectorp def))
"a keyboard macro")
***************
*** 358,365 ****
(re-search-backward "`\\([^`']+\\)'" nil t)
(help-xref-button 1 'help-function-def real-function file-name))))
(princ ".")
! (terpri)
(when (commandp function)
(if (and (eq function 'self-insert-command)
(eq (key-binding "a") 'self-insert-command)
(eq (key-binding "b") 'self-insert-command)
--- 359,370 ----
(re-search-backward "`\\([^`']+\\)'" nil t)
(help-xref-button 1 'help-function-def real-function file-name))))
(princ ".")
! (with-current-buffer (help-buffer)
! (fill-region-as-paragraph (save-excursion (goto-char pt1) (forward-line 0) (point))
! (point)))
! (terpri)(terpri)
(when (commandp function)
+ (let ((pt2 (with-current-buffer (help-buffer) (point))))
(if (and (eq function 'self-insert-command)
(eq (key-binding "a") 'self-insert-command)
(eq (key-binding "b") 'self-insert-command)
***************
*** 379,385 ****
(princ "'"))
(when keys
! (princ (if remapped " which is bound to " "It is bound to "))
;; If lots of ordinary text characters run this command,
;; don't mention them one by one.
(if (< (length non-modified-keys) 10)
--- 384,390 ----
(princ "'"))
(when keys
! (princ (if remapped ", which is bound to " "It is bound to "))
;; If lots of ordinary text characters run this command,
;; don't mention them one by one.
(if (< (length non-modified-keys) 10)
***************
*** 393,399 ****
(princ "many ordinary text characters"))))
(when (or remapped keys non-modified-keys)
(princ ".")
! (terpri)))))
(let* ((arglist (help-function-arglist def))
(doc (documentation function))
(usage (help-split-fundoc doc function)))
--- 398,406 ----
(princ "many ordinary text characters"))))
(when (or remapped keys non-modified-keys)
(princ ".")
! (terpri))))
! (with-current-buffer (help-buffer) (fill-region-as-paragraph pt2 (point)))
! (terpri)))
(let* ((arglist (help-function-arglist def))
(doc (documentation function))
(usage (help-split-fundoc doc function)))
Diff finished. Mon Feb 11 14:29:35 2008
[-- Attachment #3: help-2008-02-11.patch --]
[-- Type: application/octet-stream, Size: 2164 bytes --]
diff -c -w help-CVS-2008-02-11.el help-patched-2008-02-11.el
*** help-CVS-2008-02-11.el Mon Feb 11 14:34:04 2008
--- help-patched-2008-02-11.el Mon Feb 11 14:45:52 2008
***************
*** 745,752 ****
(with-help-window (help-buffer)
(princ (help-key-description key untranslated))
(princ (format "\
! %s runs the command %S
! which is "
mouse-msg defn))
(describe-function-1 defn)
(when up-event
--- 745,751 ----
(with-help-window (help-buffer)
(princ (help-key-description key untranslated))
(princ (format "\
! %s runs the command %S, which is "
mouse-msg defn))
(describe-function-1 defn)
(when up-event
***************
*** 757,768 ****
----------------- up-event %s----------------
! <%S>%s%s runs the command %S
! which is "
(if mouse-1-tricky "(short click) " "")
ev-type mouse-msg
(if mouse-1-remapped
! " is remapped to <mouse-2>\nwhich" "")
defn-up))
(describe-function-1 defn-up))
(unless (or (null defn-up-tricky)
--- 756,766 ----
----------------- up-event %s----------------
! <%S>%s%s runs the command %S, which is "
(if mouse-1-tricky "(short click) " "")
ev-type mouse-msg
(if mouse-1-remapped
! " is remapped to <mouse-2>, which" "")
defn-up))
(describe-function-1 defn-up))
(unless (or (null defn-up-tricky)
***************
*** 773,780 ****
----------------- up-event (long click) ----------------
Pressing <%S>%s for longer than %d milli-seconds
! runs the command %S
! which is "
ev-type mouse-msg
mouse-1-click-follows-link
defn-up-tricky))
--- 771,777 ----
----------------- up-event (long click) ----------------
Pressing <%S>%s for longer than %d milli-seconds
! runs the command %S, which is "
ev-type mouse-msg
mouse-1-click-follows-link
defn-up-tricky))
Diff finished. Mon Feb 11 14:46:11 2008
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: patch to fill overlong lines in `describe-key'
2008-02-12 6:18 Drew Adams
@ 2008-02-12 7:11 ` Bastien
0 siblings, 0 replies; 3+ messages in thread
From: Bastien @ 2008-02-12 7:11 UTC (permalink / raw)
To: Drew Adams; +Cc: emacs-devel
I have applied these patches.
"Drew Adams" <drew.adams@oracle.com> writes:
> I mistakenly sent the wrong patch for help-fns.el. I sent a patch that added
> command `describe-option' and such - something unrelated. Attached are
> updated patches wrt today's CVS.
>
> And here's a change log entry:
>
> 2008-02-11 Drew Adams <drew.adams@oracle.com>
>
> * help.el (describe-key): Joined some split lines to facilitate
> filling.
> * help-fns.el (describe-function-1): Fill text of overlong lines.
--
Bastien
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-02-12 7:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-03 19:59 patch to fill overlong lines in `describe-key' Drew Adams
-- strict thread matches above, loose matches on Subject: below --
2008-02-12 6:18 Drew Adams
2008-02-12 7:11 ` Bastien
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.