all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Le Wang <l26wang@gmail.com>
To: "Steven W. Orr" <steveo@syslang.net>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Looking for CDPATH functionality in emacs.
Date: Tue, 4 Jan 2011 12:42:42 +0800	[thread overview]
Message-ID: <AANLkTinpvvL+S_mTjNY0U-X0RK=BWCQOsqeUAKoBAa-=@mail.gmail.com> (raw)
In-Reply-To: <4D221B85.5040702@syslang.net>

[-- Attachment #1: Type: text/plain, Size: 1405 bytes --]

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.html


> 2. 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 with
nothing 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

[-- Attachment #2: Type: text/html, Size: 3027 bytes --]

  parent reply	other threads:[~2011-01-04  4:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-03 18:55 Looking for CDPATH functionality in emacs Steven W. Orr
2011-01-03 19:08 ` Thien-Thi Nguyen
2011-01-03 19:20 ` Drew Adams
2011-01-03 20:16 ` Peter Dyballa
2011-01-04  4:42 ` Le Wang [this message]
2011-01-04  9:43   ` Le Wang
2011-01-04  5:55 ` Kevin Rodgers
2011-01-06  0:37 ` DevZero
     [not found] <mailman.12.1294080915.3992.help-gnu-emacs@gnu.org>
2011-01-06  9:40 ` Stefan Kamphausen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTinpvvL+S_mTjNY0U-X0RK=BWCQOsqeUAKoBAa-=@mail.gmail.com' \
    --to=l26wang@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=steveo@syslang.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.