From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Le Wang Newsgroups: gmane.emacs.help Subject: Re: Looking for CDPATH functionality in emacs. Date: Tue, 4 Jan 2011 12:42:42 +0800 Message-ID: References: <4D221B85.5040702@syslang.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=0016e65b40f626cde50498fde642 X-Trace: dough.gmane.org 1294116199 30372 80.91.229.12 (4 Jan 2011 04:43:19 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 4 Jan 2011 04:43:19 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: "Steven W. Orr" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jan 04 05:43:15 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PZyjn-0007ni-HA for geh-help-gnu-emacs@m.gmane.org; Tue, 04 Jan 2011 05:43:11 +0100 Original-Received: from localhost ([127.0.0.1]:50976 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PZyjm-0002HS-Ky for geh-help-gnu-emacs@m.gmane.org; Mon, 03 Jan 2011 23:43:10 -0500 Original-Received: from [140.186.70.92] (port=53762 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PZyjS-0002HK-1l for help-gnu-emacs@gnu.org; Mon, 03 Jan 2011 23:42:51 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PZyjQ-0006z2-G8 for help-gnu-emacs@gnu.org; Mon, 03 Jan 2011 23:42:49 -0500 Original-Received: from mail-ey0-f169.google.com ([209.85.215.169]:62293) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PZyjQ-0006yn-6d for help-gnu-emacs@gnu.org; Mon, 03 Jan 2011 23:42:48 -0500 Original-Received: by eyh6 with SMTP id 6so3107889eyh.0 for ; Mon, 03 Jan 2011 20:42:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=WZ5pu+MsqzCzmzsdDkQEZy/Rpnhje6SljVW76xCgxSc=; b=KktTCLARYpW3ypP3N0ycO2D8E4nKK3WbjJZ1DaCfis06cCh07cEZCA9UaUozuT4RQU apiA+0Yw5Yfaf84WKeL3a6nohccxF+rI5KQ16ILZCrOiA0LZOACS3kgjWfMi4nrs1Lpu teioCd9LLprRPBotGxZh8oV460+f+5mBssTJk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=TsnimJZhTihGVb41KPoEzLcSt554d563U5p9t8t+KVm9w2cGF1hZz4O1wyHB0aYbvM n1cjv8htYaZg//Q8ZG3taLtFqGTBP97+mtSS9+MqE3UxZmxGdlw31UVto1QlaFPsQUdG 0JuTxzGL8ssw5v/98dEsTlynsqNGer+YDcoVQ= Original-Received: by 10.14.17.193 with SMTP id j41mr12025591eej.38.1294116162292; Mon, 03 Jan 2011 20:42:42 -0800 (PST) Original-Received: by 10.14.119.11 with HTTP; Mon, 3 Jan 2011 20:42:42 -0800 (PST) In-Reply-To: <4D221B85.5040702@syslang.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:78147 Archived-At: --0016e65b40f626cde50498fde642 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Jan 4, 2011 at 2:55 AM, Steven W. Orr 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 my-find-file, "spec", ae, it should expand do what you want. You can bind expansion to a shorter chord if you like. -- Le --0016e65b40f626cde50498fde642 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Tue, Jan 4, 2011 at 2:55 AM, Steven W. Orr <steveo@syslang.ne= t> 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). =A0I don't use them heav= ily myself, but here is a tutorial:=A0http://xahlee.org/emacs/emacs_abbrev_mode.html
=A0
2. Can I fix my-visit-file so that a C-u will prevent the default prompt fr= om
being the current directory of the file I'm starting from? (But I do st= ill
want filename completion.)
=A0
Read the file= name yourself, so you can have control:

(defun my-visit-file (arg)
=
=A0"Visit a file using comp= letion. If there is only one window with
nothing in it, then do not split the current window. "
=
=A0(interactive "P&qu= ot;)
=A0(let ((insert= -default-directory t)
=A0=A0 =A0 =A0 my-file)
=A0=A0 (when (equal arg= '(4))
=A0=A0 =A0= (setq insert-default-directory nil))
=A0=A0 (setq my-file (read= -file-name "my-visit-file: "))
=A0=A0 (if (and (one-window-p) (zerop (buffer-size)))
=A0=A0 =A0 =A0 (find-file my-fil= e)
=A0=A0 =A0 (find-f= ile-(or =A0)ther-window my-file))))

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

You= can read the doc on `read-file-name' and `insert-default-directory'= ; for yourself. =A0I've also added an abbrev table entry for "spec= ". =A0So, 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.<= /div>

--
Le
--0016e65b40f626cde50498fde642--