emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

patch for woman (woman-topic-at-point)


From: Emilio Lopes
Subject: patch for woman (woman-topic-at-point)
Date: Thu, 25 Aug 2005 20:48:30 +0200
User-agent: Emacs Gnus

[ 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  <address@hidden>

        * 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 <address@hidden>
  ;;   Eli Zaretskii <address@hidden>
  
- ;;; History:
- ;;  For recent change log see end of file.
- 
  
  ;;; 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.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]