* choose-completion-string should not exit minibuffer upon lisp-complete-symbol
@ 2004-09-21 22:28 Drew Adams
0 siblings, 0 replies; 2+ messages in thread
From: Drew Adams @ 2004-09-21 22:28 UTC (permalink / 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: choose-completion-string should not exit minibuffer upon lisp-complete-symbol
[not found] <mailman.3536.1095806096.1998.bug-gnu-emacs@gnu.org>
@ 2004-09-22 15:40 ` Kevin Rodgers
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Rodgers @ 2004-09-22 15:40 UTC (permalink / raw
Drew Adams wrote:
> 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.
Note that "(sear" can only complete to "(search-", since it matches the
search-forward, search-backward, search-forward-regexp, and
search-backward-regexp functions.
> 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).
No, the problem does not exist in Emacs 21.3, when started with the -q
--no-site-file options.
> 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.
I suspect elect-mbuf.el is the cause of the problem.
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-09-22 15:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[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
2004-09-21 22:28 Drew Adams
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.