unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / 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 17:43:07 +0800	[thread overview]
Message-ID: <AANLkTi=PgQG_-RfYDctMpAY-Le+N-JZ37jXAp6w=Mt3Z@mail.gmail.com> (raw)
In-Reply-To: <AANLkTinpvvL+S_mTjNY0U-X0RK=BWCQOsqeUAKoBAa-=@mail.gmail.com>

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

Sorry, I'm trying out yasnippet, and it expanded something in the code
accidentally.  Here is the right bits:

(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-ther-window my-file))))

(define-abbrev-table 'global-abbrev-table
  '(("spec" "/path/to/special/dir" nil 0)))



On Tue, Jan 4, 2011 at 12:42 PM, Le Wang <l26wang@gmail.com> wrote:

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



-- 
Le

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

  reply	other threads:[~2011-01-04  9:43 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
2011-01-04  9:43   ` Le Wang [this message]
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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to='AANLkTi=PgQG_-RfYDctMpAY-Le+N-JZ37jXAp6w=Mt3Z@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).