unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
Subject: choose-completion-string should not exit minibuffer upon lisp-complete-symbol
Date: Tue, 21 Sep 2004 15:28:22 -0700	[thread overview]
Message-ID: <MEEKKIABFKKDFJMPIOEBGEEJCGAA.drew.adams@oracle.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 3175 bytes --]

This is more of an enhancement suggestion than a bug report.

If you are entering Lisp code for evaluation (e.g. `M-:'), then you don't
want to exit the minibuffer when you complete a Lisp symbol. For example,
you have "(sear" when you use `lisp-complete-symbol' to pick
`search-forward'; you want the minibuffer to have "(search-forward" and let
you continue to type code.

For this reason, I modified choose-completion-string to recognize this.
Below is my version from Emacs 20, but I think the code is about the same
for Emacs 21 (the "problem" is still there, in any case). My code uses
variable command-calling-for-completion from library `elect-mbuf.el', but
the test could be done differently. That variable just holds the last
command that caused display of the list of possible completions.

;; REPLACES ORIGINAL in `simple.el':
;; Don't exit minibuffer if this is just a `lisp-complete-symbol'
completion.
(defun choose-completion-string (choice &optional buffer base-size)
  "Switch to BUFFER and insert the completion choice CHOICE.
BASE-SIZE, if non-nil, says how many chars of BUFFER's text to keep.
If it is nil, use `choose-completion-delete-max-match' instead.
If BUFFER is the minibuffer, then exit the minibuffer, unless:
   - it is reading a file name and CHOICE is a directory, *or*
   - `completion-no-auto-exit' is non-nil, *or*
   - this is just a `lisp-complete-symbol' completion."
  (let ((buffer (or buffer completion-reference-buffer))) ; In `simple.el'.
    ;; If BUFFER is a minibuffer, barf unless it's currently active.
    (when (and (string-match "\\` \\*Minibuf-[0-9]+\\*\\'"
                             (buffer-name buffer))
               (or (not (active-minibuffer-window))
                   (not (equal buffer
                               (window-buffer
(active-minibuffer-window))))))
      (error "Minibuffer is not active for completion."))
    ;; Insert the completion into the buffer where completion was requested.
    (set-buffer buffer)
    (if base-size
        (delete-region (+ base-size (point-min)) (point))
      (choose-completion-delete-max-match choice))
    (insert choice)
    (remove-text-properties (- (point) (length choice)) (point)
                            '(mouse-face nil))
    ;; Update point in the window that BUFFER is showing in.
    (let ((window (get-buffer-window buffer t)))
      (set-window-point window (point)))
    ;; If completing for the minibuffer, exit it with this choice,
    ;; unless this was a `lisp-complete-symbol' completion.
    (and (not completion-no-auto-exit)
         (equal buffer (window-buffer (minibuffer-window)))
         minibuffer-completion-table
         (not (and (boundp 'command-calling-for-completion) ; Defined in
`elect-mbuf.el'.
                   (eq 'lisp-complete-symbol
command-calling-for-completion)))
         ;; If this is reading a file name, and the file name chosen
         ;; is a directory, don't exit the minibuffer.
         (if (and (eq minibuffer-completion-table 'read-file-name-internal)
                  (file-directory-p (buffer-string)))
             (select-window (active-minibuffer-window))
           (exit-minibuffer)))))

[-- Attachment #1.2: Type: text/html, Size: 5840 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
Bug-gnu-emacs mailing list
Bug-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs

             reply	other threads:[~2004-09-21 22:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-21 22:28 Drew Adams [this message]
     [not found] <mailman.3536.1095806096.1998.bug-gnu-emacs@gnu.org>
2004-09-22 15:40 ` choose-completion-string should not exit minibuffer upon lisp-complete-symbol Kevin Rodgers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MEEKKIABFKKDFJMPIOEBGEEJCGAA.drew.adams@oracle.com \
    --to=drew.adams@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).