[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: file name aliases, bookmarks and abbrevs
From: |
Matthias Meulien |
Subject: |
Re: file name aliases, bookmarks and abbrevs |
Date: |
12 Jul 2003 19:59:44 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.93 |
"Stefan Monnier" <monnier+gnu.emacs.help/news/@flint.cs.yale.edu> wrote:
> (...) You could even check minibuffer-completing-file-name in
> my-setup-minibuffer-abbrev so the abbrev is only active when
> entering a file name.
Good idea. Here is the new code:
(defvar bookmarks-abbrevs-table (make-abbrev-table))
(defun bookmarks-abbrevs-build-table ()
"Initialize `bookmarks-abbrevs-table' from `bookmark-alist'
contents."
(dolist (bookmark bookmark-alist)
(let* ((name (car bookmark))
(file (bookmark-get-filename name)))
(define-abbrev bookmarks-abbrevs-table name file))))
(defun bookmarks-abbrevs-setup ()
"Initialize use of bookmarks abbreviations for filename completion
in the minibuffer."
(require 'bookmark)
(if bookmarks-already-loaded (bookmarks-abbrevs-build-table))
(make-local-hook 'pre-abbrev-expand-hook)
(add-hook 'pre-abbrev-expand-hook
'bookmarks-abbrevs-pre-expand-hook nil t))
(defun bookmarks-abbrevs-pre-expand-hook ()
"When completing a filename, install `bookmarks-abbrevs-table' as
the local abbrev table.
Then does expansion"
(if minibuffer-completing-file-name
(progn
;; Note that we cannot use abbrevs described in
;; `fundamental-abbrevs-table'
(setq local-abbrev-table bookmarks-abbrevs-table)
(let ((pre-abbrev-expand-hook nil))
(expand-abbrev))
(setq local-abbrev-table fundamental-mode-abbrev-table))))
(add-hook 'minibuffer-setup-hook 'bookmarks-abbrevs-setup)
Thank you very much Stephan.
Now the code lacks a syntax table hack to accept abbrevs with
spaces...
--
Matthias
- file name aliases, bookmarks and abbrevs, Matthias Meulien, 2003/07/09
- Re: file name aliases, bookmarks and abbrevs, Kevin Rodgers, 2003/07/09
- Re: file name aliases, bookmarks and abbrevs, Kai Großjohann, 2003/07/09
- Re: file name aliases, bookmarks and abbrevs, Stefan Monnier, 2003/07/10
- Re: file name aliases, bookmarks and abbrevs,
Matthias Meulien <=