|
From: | Le Wang |
Subject: | Re: Looking for CDPATH functionality in emacs. |
Date: | Tue, 4 Jan 2011 17:43:07 +0800 |
(defun my-visit-file (arg)"Visit a file using completion. If there is only one window withnothing in it, then do not split the current window. "(interactive "P")(let ((insert-default-directory t)my-file)(when (equal arg '(4))(setq insert-default-directory nil))(setq my-file (read-file-name "my-visit-file: "))(if (and (one-window-p) (zerop (buffer-size)))(find-file my-file)(find-file-ther-window my-file))))(define-abbrev-table 'global-abbrev-table'(("spec" "/path/to/special/dir" nil 0)))
On Tue, Jan 4, 2011 at 2:55 AM, Steven W. Orr <steveo@syslang.net> wrote:So, if you made it this far, here's the recap:
1. Does anything already exist that smells like what I want?Yes, abbrev (see below). I don't use them heavily myself, but here is a tutorial: http://xahlee.org/emacs/emacs_abbrev_mode.html2. Can I fix my-visit-file so that a C-u will prevent the default prompt from
being the current directory of the file I'm starting from? (But I do still
want filename completion.)Read the filename yourself, so you can have control:(defun my-visit-file (arg)"Visit a file using completion. If there is only one window withnothing in it, then do not split the current window. "(interactive "P")(let ((insert-default-directory t)my-file)(when (equal arg '(4))(setq insert-default-directory nil))(setq my-file (read-file-name "my-visit-file: "))(if (and (one-window-p) (zerop (buffer-size)))(find-file my-file)(find-file-(or )ther-window my-file))))
(define-abbrev-table 'global-abbrev-table'(("spec" "/path/to/special/dir" nil 0)))--You can read the doc on `read-file-name' and `insert-default-directory' for yourself. I've also added an abbrev table entry for "spec". So, if you <C-u>my-find-file, "spec", <C-x>ae, it should expand do what you want.You can bind expansion to a shorter chord if you like.
Le
[Prev in Thread] | Current Thread | [Next in Thread] |