all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* patch for woman (woman-topic-at-point)
@ 2005-08-25 18:48 Emilio Lopes
  2005-08-25 19:51 ` David Kastrup
  2005-08-26 12:03 ` Richard M. Stallman
  0 siblings, 2 replies; 17+ messages in thread
From: Emilio Lopes @ 2005-08-25 18:48 UTC (permalink / raw)


[ Sorry for the long message.  I wanted to make the problem clear
  also for people not familiar with `woman'. ]

The variable `woman-topic-at-point' controls whether the command
`woman' should offer the word at point as a suggestion when asking the
user for the name of a manual page.

The default value is `confirm' and being neither t nor nil means to
use the word at point as a suggestion but give the user the option to
reject or confirm this suggestion.

The problem is that "to suggest" for `woman' means to actually
*insert* the suggested name in the minibuffer, a behavior described
as deprecated in the documentation of `completing-read'.

And because the word at point rarely (at least for me) is the name of a
man page actually installed in the system, this means that most of the
time the user has the burden of having to delete the useless suggestion
before entering the desired man page.  I find this annoying.

The following patch introduces a new possible value for
`woman-topic-at-point': if this variable is the symbol `exact',
`woman' will offer the word at point as a default ONLY IF it actually
matches the name of an existing man page in the system.  Even in this
case it will *not* insert the suggestion in the minibuffer.

This change is backwards compatible.

If I could only change the behavior of *any* woman with a patch :-)


2005-08-19  Emilio C. Lopes  <eclig@gmx.net>

	* woman.el (woman-topic-at-point-default, woman-topic-at-point):
	new possible value `exact'.
	(woman-file-name): support for this new value of
	`woman-topic-at-point'.


diff -rN -c old-emacs-darcs.eclig/lisp/woman.el new-emacs-darcs.eclig/lisp/woman.el
*** old-emacs-darcs.eclig/lisp/woman.el	Thu Aug 25 19:59:24 2005
--- new-emacs-darcs.eclig/lisp/woman.el	Fri Aug 19 18:07:36 2005
***************
*** 144,151 ****
  ;; topic must be confirmed or edited in the minibuffer.  This
  ;; suggestion can be turned off, or `woman' can use the suggested
  ;; topic without confirmation* if possible, by setting the user-option
! ;; `woman-topic-at-point' to nil or t respectively.  (Its default
! ;; value is neither nil nor t, meaning ask for confirmation.)
  
  ;; [* Thanks to Benjamin Riefenstahl for suggesting this
  ;; functionality.]
--- 144,153 ----
  ;; topic must be confirmed or edited in the minibuffer.  This
  ;; suggestion can be turned off, or `woman' can use the suggested
  ;; topic without confirmation* if possible, by setting the user-option
! ;; `woman-topic-at-point' to nil or t respectively.  If it is the
! ;; symbol `exact' then the word at point will be offered as a
! ;; suggestion only if it is an exact match for an existing topic.
! ;; (Its default value is none of these, meaning ask for confirmation.)
  
  ;; [* Thanks to Benjamin Riefenstahl for suggesting this
  ;; functionality.]
***************
*** 422,430 ****
  ;;   Geoff Voelker <voelker@cs.washington.edu>
  ;;   Eli Zaretskii <eliz@is.elta.co.il>
  
- ;;; History:
- ;;  For recent change log see end of file.
- 
  \f
  ;;; Code:
  
--- 424,429 ----
***************
*** 721,738 ****
    "*Default value for `woman-topic-at-point'."
    :type '(choice (const :tag "Yes" t)
  		 (const :tag "No" nil)
  		 (other :tag "Confirm" confirm))
    :group 'woman-interface)
  
  (defcustom woman-topic-at-point woman-topic-at-point-default
    "*Controls use by `woman' of `word at point' as a topic suggestion.
! If non-nil then the `woman' command uses the word at point as an
! initial topic suggestion when it reads a topic from the minibuffer; if
! t then the `woman' command uses the word at point WITHOUT
! INTERACTIVE CONFIRMATION if it exists as a topic.  The default value
! is `confirm', meaning suggest a topic and ask for confirmation."
    :type '(choice (const :tag "Yes" t)
  		 (const :tag "No" nil)
  		 (other :tag "Confirm" confirm))
    :group 'woman-interface)
  
--- 720,743 ----
    "*Default value for `woman-topic-at-point'."
    :type '(choice (const :tag "Yes" t)
  		 (const :tag "No" nil)
+                  (const :tag "Exact" exact)
  		 (other :tag "Confirm" confirm))
    :group 'woman-interface)
  
  (defcustom woman-topic-at-point woman-topic-at-point-default
    "*Controls use by `woman' of `word at point' as a topic suggestion.
! If t then the `woman' command uses the word at point WITHOUT
! INTERACTIVE CONFIRMATION if it exists as a topic.
! If it is the symbol `exact' then the word at point will be offered
! as a suggestion only if it is an exact match for an existing topic.
! If it has other non-nil value then the `woman' command uses the word
! at point as an initial topic suggestion when it reads a topic from
! the minibuffer.
! The default value is `confirm', meaning suggest a topic and ask
! for confirmation."
    :type '(choice (const :tag "Yes" t)
  		 (const :tag "No" nil)
+                  (const :tag "Exact" exact)
  		 (other :tag "Confirm" confirm))
    :group 'woman-interface)
  
***************
*** 956,963 ****
      :group 'woman-faces)
  
    (defcustom woman-use-symbol-font nil
!     "*If non-nil then may use the symbol font.  It is off by default,
! mainly because it may change the line spacing (in NTEmacs 20.5)."
      :type 'boolean
      :group 'woman-faces)
  
--- 961,969 ----
      :group 'woman-faces)
  
    (defcustom woman-use-symbol-font nil
!     "*If non-nil then may use the symbol font.
! It is off by default,mainly because it may change the line spacing
! \(in NTEmacs 20.5)."
      :type 'boolean
      :group 'woman-faces)
  
***************
*** 1229,1245 ****
  		   ;; Was let-bound when file loaded, so ...
  		   (setq woman-topic-at-point woman-topic-at-point-default)))
  	     (setq topic
! 		   (or (current-word t) ""))	; only within or adjacent to word
  	     (assoc topic woman-topic-all-completions))
  	(setq topic
! 	      (completing-read
! 	       "Manual entry: "
! 	       woman-topic-all-completions nil 1
! 	       ;; Initial input suggestion (was nil), with
! 	       ;; cursor at left ready to kill suggestion!:
! 	       (and woman-topic-at-point
! 		    (cons (or (current-word) "") 0)) ; nearest word
! 	       'woman-topic-history)))
      ;; Note that completing-read always returns a string.
      (if (= (length topic) 0)
  	nil				; no topic, so no file!
--- 1235,1266 ----
  		   ;; Was let-bound when file loaded, so ...
  		   (setq woman-topic-at-point woman-topic-at-point-default)))
  	     (setq topic
! 		   (or (current-word t) "")) ; only within or adjacent to word
  	     (assoc topic woman-topic-all-completions))
  	(setq topic
!               (let (initial default)
!                 (cond
!                  ((eq woman-topic-at-point 'exact)
!                   (setq initial nil)
!                   (setq default (and (current-word)
!                                      (car (assoc (current-word)
!                                                  woman-topic-all-completions)))))
!                  (woman-topic-at-point  ; any other non-nil value
!                   ;; Initial input suggestion, with cursor at left
!                   ;; ready to kill suggestion!
!                   (setq initial (cons (or (current-word) "") 0))
!                   (setq default nil))
!                  (t
!                   (setq initial nil)
!                   (setq default nil)))
!                 (completing-read
!                  (if default
!                      (format "Manual entry [default: %s]: " default)
!                    "Manual entry: ")
!                  woman-topic-all-completions nil 1
!                  initial
!                  'woman-topic-history
!                  default))))
      ;; Note that completing-read always returns a string.
      (if (= (length topic) 0)
  	nil				; no topic, so no file!
***************
*** 1259,1268 ****
  	;; Unread the command event (TAB = ?\t = 9) that runs the command
  	;; `minibuffer-complete' in order to automatically complete the
  	;; minibuffer contents as far as possible.
! 	(setq unread-command-events '(9))	; and delete any type-ahead!
  	(completing-read "Manual file: " files nil 1
! 			 (try-completion "" files) 'woman-file-history)))
!       )))
  
  (defun woman-select (predicate list)
    "Select unique elements for which PREDICATE is true in LIST.
--- 1280,1288 ----
  	;; Unread the command event (TAB = ?\t = 9) that runs the command
  	;; `minibuffer-complete' in order to automatically complete the
  	;; minibuffer contents as far as possible.
! 	(setq unread-command-events '(9)) ; and delete any type-ahead!
  	(completing-read "Manual file: " files nil 1
! 			 (try-completion "" files) 'woman-file-history))))))
  
  (defun woman-select (predicate list)
    "Select unique elements for which PREDICATE is true in LIST.

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

end of thread, other threads:[~2005-09-02 11:11 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-25 18:48 patch for woman (woman-topic-at-point) Emilio Lopes
2005-08-25 19:51 ` David Kastrup
2005-08-26 12:03 ` Richard M. Stallman
2005-08-26 15:21   ` Emilio Lopes
2005-08-26 18:05     ` Stefan Monnier
2005-08-27 18:57       ` Emilio Lopes
2005-08-28 19:35         ` David Kastrup
2005-08-29 16:08           ` Drew Adams
2005-08-30 16:13             ` Emilio Lopes
2005-08-29 18:08           ` Emilio Lopes
2005-08-29 20:56             ` Stefan Monnier
2005-08-29 22:15               ` Thien-Thi Nguyen
2005-08-31  2:28                 ` Stefan Monnier
2005-08-28  2:45     ` Richard M. Stallman
2005-09-02 11:11       ` Dr Francis J Wright
2005-08-26 15:23   ` Emilio Lopes
2005-08-26 16:25   ` Dr Francis J Wright

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.