emacs-devel
[Top][All Lists]
Advanced

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

dabbrev-expand for the minibuffer


From: Dan Nicolaescu
Subject: dabbrev-expand for the minibuffer
Date: Sat, 23 Feb 2008 14:59:06 -0800

A lot of times when using dabbrev-expand in the minibuffer, the most
desirable expansion is something from the minibuffer history.
But dabbrev-expand does not search the minibuffer history...
If for example you use M-x compile a lot with a lot of very complex
command lines, having dabbrev-expand look in the minibuffer history is
very useful.
(This is not unlike what you suffer from when using bash: no dabbrev-expand at 
all).

So a long time ago I wrote this hack to put the minibuffer history in a
buffer and tell dabbrev to search it too.

(setq dabbrev-select-buffers-function 'my-minibuffer-setup-dabbrev-buffers)

(defun my-minibuffer-setup-dabbrev-buffers ()
  (let ((buf (get-buffer-create " *dabbrev history* ")))
    (save-excursion 
      (set-buffer buf)
      (erase-buffer)
      ;; dabbrev looks for text only in buffers.  Put the minibuffer
      ;; history in a buffer, so that dabbrev can look at it.
      (mapc (lambda (arg) 
            (insert arg "\n")) 
                (if minibuffer-history-variable 
                    (eval minibuffer-history-variable)
                          minibuffer-history)))
    ;; Put the minibuffer history at the beginning of the buffer list
    ;; that dabbrev will look at.
    (append (list buf) (dabbrev--select-buffers))))

I am not sure what is the proper way to integrate this functionality,
it would be great if someone that knows dabbrev could either add
something similar to this code, or do it in a better way and provide it
by default.  

Thanks

        --dan




reply via email to

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