[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `g' and `G' do not provide current url as the initial minibuffer contents
- From: Michael Heerdegen <michael_heerdegen@xxxxxx>
- Date: Thu, 31 Jul 2014 18:12:10 +0200
- X-ml-name: emacs-w3m
- X-mail-count: 12370
- References: <86a97xvd4v.fsf@xxxxxxxxxxxxxxxxxxxx> <878une21jz.fsf@xxxxxx> <b4mzjfu5pzg.fsf@xxxxxxx> <8638dlve9x.fsf@xxxxxxxxxxxxxxxxxxxx> <b4ma97thrbm.fsf@xxxxxxx> <86zjfs1ii9.fsf@xxxxxxxxxxxxxxxxxxxx> <b4mbns7sqew.fsf@xxxxxxx> <8761if3w8p.fsf@xxxxxx> <b4md2cmulqn.fsf@xxxxxxx>
Katsumi Yamaoka <yamaoka@xxxxxxx> writes:
(B> I tried to use `minibuffer-default-add-function' first, but
(B> failed. The custom function set to it didn't seem to be called.
(B> What I did was:
(B> (defun w3m-input-url-default-add-completions ()
(B> "Use the current url string (if any) as the next history by default.
(B> This function is used as `minibuffer-default-add-function'."
(B> (w3m-static-when (fboundp 'minibuffer-default-add-completions)
(B> (let ((minibuffer-default
(B> (or (with-current-buffer
(B> (window-buffer (minibuffer-selected-window))
(B> (or (w3m-active-region-or-url-at-point) w3m-current-url))
(BIt actually is called, but I think it is just written in an illegitimate
(Bway and doesn't work correctly.
(BYou must not shadow the variable `minibuffer-default', because it is
(Balready bound to the DEFAULT-VALUE argument of `read-from-minibuffer,
(Be.g. "about:". Rebinding this variable obviously confuses Emacs. Here
(Bis a version that works for me:
(B(defun w3m-input-url-default-add-completions ()
(B "Use the current url string (if any) as the next history by default.
(BThis function is used as `minibuffer-default-add-function'."
(B (w3m-static-when (fboundp 'minibuffer-default-add-completions)
(B (let ((to-add (with-current-buffer
(B (window-buffer (minibuffer-selected-window))
(B (or (w3m-active-region-or-url-at-point) w3m-current-url)))
(B (def minibuffer-default)
(B (all (all-completions ""
(B (listify (lambda (thing) (if (listp thing) thing (list thing)))))
(B (append (funcall listify def)
(B (funcall listify to-add)
(BThere is probably no sane solution that calls
(B`minibuffer-default-add-completions' and avoids code duplication.
(BNote that in the list returned by
(B`w3m-input-url-default-add-completions' the current value of
(B`minibuffer-default' must be the first element; else, the thing doesn't
(BSo, if you want the current url to be the first candidate when hitting
(BM-n, you must make it the DEFAULT-VALUE of `read-from-minibuffer'.
(B> (defun w3m-input-url (...)
(BThat part should be ok.
(BBTW, which Emacs versions do we need to support? Because, starting with
(BEmacs 23, the DEFAULT-VALUE argument of `read-from-minibuffer' is
(Ballowed to be a list of several defaults. When we would use this
(Bfeature, everything would become trivially simple.