bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#10998: Allow movements in bookmark-bmenu-search


From: Thierry Volpiatto
Subject: bug#10998: Allow movements in bookmark-bmenu-search
Date: Mon, 01 Oct 2012 09:45:42 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)

Karl Fogel <kfogel@openitp.org> writes:

> The code has changed somewhat since the original patch -- it now uses
> `pcase' instead of `case', for example (and thus `_' instead of `t'),
> ever since monnier@iro.umontreal.ca-20120710115154-012cs2xbndtlpvh1.
>
> Furthermore, in http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10998#11
> Thierry said "the patch sent contain free-variables, it is fixed here"
> but there was no new patch attached.
It is fixed "here" mean I fixed this on my own version of bookmark but
didn't send any patch because no body was interested by this change.
It is working with no problem since then.

> So, I've adjusted the original patch (see below) and done some light
> testing, but I'm not confident enough in this to commit it yet.
> Thierry, what were those free variables?
Don't remember that was more than one year ago.


> And can you test this to make sure it behaves as your original patch
> did?
I have not anymore this patch.
You will find bookmark-extensions.el at:
https://github.com/thierryvolpiatto/emacs-bmk-ext.git
Install it and try cursor movements to see if it behave like your patch.

Here the function:


#+BEGIN_SRC lisp
(defun bookmark-read-search-input ()
  "Read each keyboard input and add it to `bookmark-search-pattern'."
  (let ((prompt       (propertize "Pattern: " 'face 'minibuffer-prompt))
        (tmp-list     ())
        (index        0))
    (while
        (let ((char (read-key (concat prompt (bookmark-set-cursor-in-prompt
                                              bookmark-search-pattern
                                              index tmp-list)))))
          (case char
            ((?\e ?\r) nil) ; RET or ESC break the search loop.
            (?\C-g (setq bookmark-quit-flag t) nil)
            (?\d (with-no-warnings ; Delete last char of pattern with DEL.
                   (pop (nthcdr index tmp-list))) t)
            ;; Movements in minibuffer.
            (?\C-b                         ; backward-char.
             (setq index (min (1+ index) (length tmp-list))) t)
            (?\C-f                         ; forward-char.
             (setq index (max (1- index) 0)) t)
            (?\C-a                         ; move bol.
             (setq index (length tmp-list)) t)
            (?\C-e                         ; move eol.
             (setq index 0) t)
            (?\C-k
             (kill-new (substring bookmark-search-pattern
                                  (- (length tmp-list) index)))
             (setq tmp-list (nthcdr index tmp-list)) (setq index 0) t)
            (?\C-y
             (let ((str (car kill-ring)))
               (loop for char across str
                     do (push char (nthcdr index tmp-list)))) t)
            (t
             (if (characterp char)
                 (push char (nthcdr index tmp-list))
               (setq unread-command-events
                     (nconc (mapcar 'identity
                                    (this-single-command-raw-keys))
                            unread-command-events))
               nil))))
      (setq bookmark-search-pattern
            (apply 'string (reverse tmp-list))))))

#+END_SRC

Note: I don't maintain anymore bookmark-extensions.el, only small
bugfixes for my personal usage (e.g recently `bookmark-write-file')

> I agree with Stefan that this is not an ideal solution, by the way, and
> have left a comment in the patch below to that effect.
Keep in mind that this is not a real minibuffer.


-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 






reply via email to

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