From: "Drew Adams" <drew.adams@oracle.com>
To: "'Chong Yidong'" <cyd@stupidchicken.com>,
<591@emacsbugs.donarmstrong.com>,
"'Stefan Monnier'" <monnier@iro.umontreal.ca>
Subject: bug#591: 23.0.60; lisp-complete-symbol erases extra text
Date: Tue, 29 Jul 2008 14:51:42 -0700 [thread overview]
Message-ID: <004201c8f1c5$4a56e840$0200a8c0@us.oracle.com> (raw)
In-Reply-To: <87ej5czaef.fsf@stupidchicken.com>
> From: Chong Yidong Sent: Tuesday, July 29, 2008 1:46 PM
> Hi Stefan,
> This bug was introduced by your patch:
> 2008-04-13 Stefan Monnier <monnier@iro.umontreal.ca>
> minibuffer.el (display-completion-list):
> Handle all-completions's new base-size info to set
> completion-base-size.
>
> This sets completion-base-size to 0, which causes the
> completions buffer to delete everything in the Lisp
> buffer when you make a selection.
>
> I don't understand why we need the (completely undocumented)
> hack introduced here, where the cdr of the last item on the
> completions list gives completion-base-size. Does anything
> else in Emacs depend on this? Why not simply add a new
> optional argument to display-completion-list?
I won't pronounce on the hack of putting the base size into the cdr; only Stefan
knows if that is necessary and the right approach. I will say about that change
only that it required me to change my own code in a few places. For example, you
can no longer just apply `length' to the list, because it is no longer a true
list.
My reason for replying to your mail is instead to pass along the code that
Icicles uses for `choose-completion-string', in case it helps. I don't provide
it as a diff for straightforward patching, but rather as something you might
want to think about. The essential differences are these:
1. I use this:
(delete-region
(+ base-size
(if mini-p (minibuffer-prompt-end) (point-min)))
(if mini-p (point-max) (point)))
instead of this:
(delete-region (+ base-size (field-beginning)) (point))
2. After deleting the region I do this:
(when mini-p (goto-char (point-max)))
Here is my definition:
(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 characters of BUFFER's text
to keep. If it is nil, we call `choose-completion-delete-max-match'
to decide what to delete.
If BUFFER is the minibuffer, then exit the minibuffer, unless one of
the following is true:
- it is reading a file name, CHOICE is a directory, and
`icicle-dir-candidate-can-exit-p' is nil
- `completion-no-auto-exit' is non-nil
- this is just a `lisp-complete-symbol' completion."
(let* ((buffer (or buffer completion-reference-buffer))
(mini-p (minibufferp buffer)))
;; If BUFFER is a minibuffer, barf unless it's currently active.
(if (and mini-p
(or (not (active-minibuffer-window))
(not (equal buffer (window-buffer
(active-minibuffer-window))))))
(error "Minibuffer is not active for completion")
;; Set buffer so buffer-local `choose-completion-string-functions' works.
(set-buffer buffer)
(unless (run-hook-with-args-until-success
'choose-completion-string-functions
choice buffer mini-p base-size)
;; Insert completion into buffer where completion was requested.
(if base-size
(delete-region
(+ base-size (if mini-p (minibuffer-prompt-end) (point-min)))
(if mini-p (point-max) (point)))
(choose-completion-delete-max-match choice))
(when mini-p (goto-char (point-max)))
(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 0)))
(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)))
(or minibuffer-completion-table
(and icicle-mode
(or icicle-extra-candidates icicle-proxy-candidates)))
(not (eq 'lisp-complete-symbol icicle-cmd-calling-for-completion))
;; Exit the minibuffer if `icicle-dir-candidate-can-exit-p',
;; or not reading a file name, or chosen file is not a directory.
(if (or icicle-dir-candidate-can-exit-p
(not (eq minibuffer-completion-table
'read-file-name-internal))
(not (file-directory-p (field-string (point-max)))))
(exit-minibuffer)
(let ((mini (active-minibuffer-window)))
(select-window mini)
(when minibuffer-auto-raise
(raise-frame (window-frame mini))))))))))
HTH - Drew
next prev parent reply other threads:[~2008-07-29 21:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-29 20:46 bug#591: 23.0.60; lisp-complete-symbol erases extra text Chong Yidong
2008-07-29 21:51 ` Drew Adams [this message]
2008-07-29 22:07 ` Stefan Monnier
2008-07-30 4:36 ` Chong Yidong
2008-10-03 16:55 ` Drew Adams
-- strict thread matches above, loose matches on Subject: below --
2008-07-22 4:43 Drew Adams
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='004201c8f1c5$4a56e840$0200a8c0@us.oracle.com' \
--to=drew.adams@oracle.com \
--cc=591@emacsbugs.donarmstrong.com \
--cc=cyd@stupidchicken.com \
--cc=monnier@iro.umontreal.ca \
/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 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.