From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Newsgroups: gmane.emacs.help Subject: Re: opening a filename that appears in a buffer? Date: Thu, 22 May 2008 09:31:22 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <01bc057a-47b6-4f3c-9685-648babebe7c3@h1g2000prh.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1211474573 23335 80.91.229.12 (22 May 2008 16:42:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 22 May 2008 16:42:53 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu May 22 18:43:30 2008 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.50) id 1JzDsh-0005r9-SS for geh-help-gnu-emacs@m.gmane.org; Thu, 22 May 2008 18:43:08 +0200 Original-Received: from localhost ([127.0.0.1]:41209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JzDrx-0005Pw-ED for geh-help-gnu-emacs@m.gmane.org; Thu, 22 May 2008 12:42:21 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!g16g2000pri.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 76 Original-NNTP-Posting-Host: 24.6.97.120 Original-X-Trace: posting.google.com 1211473882 31055 127.0.0.1 (22 May 2008 16:31:22 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 22 May 2008 16:31:22 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: g16g2000pri.googlegroups.com; posting-host=24.6.97.120; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.1 Safari/525.18, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:158871 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:54236 Archived-At: On May 20, 12:53 pm, ljp wrote: > Hello all, > > I'm relatively new to emacs, and it is gradually becoming the central > fixture through which I do all of my programming. One thing I find > myself doing often is executing a shell command in a shell buffer, and > then wanting to open a file that was listed in the output of the shell > command. To do this right now I manually select the filename and > paste it into the minibuffer for C-x C-f. Is there an easier way? > Like, maybe, a command that is able to pick out a filename from the > buffer when the cursor is in (but not necessarily at the start of) > that filename, and then open the file in a new buffer? > > Thanks! I've looked through documentation, but I haven't found > anything like this. Some extra tips: change keybinding of M-x to M-a, so it's right under finger tip. Change keybinding of M-! to Meta-shift-a, so that M-a is to execute emacs cmd, and with shift down it runs a shell cmd. Use alias to shortern the command =E2=80=9Cshell=E2=80=9D to just =E2=80=9Cs= h=E2=80=9D. The C-x C-f is to open a file, remap it to just M-f, since Meta is right under thumb. Give find-file-at-point a shortcut of Meta shift f. So that M-f is to opens file, M-f with a dir path gives you dired, M-S-f opens the file under cursor. These are my personal settings. Here's code examples: (defalias 'sh 'shell) (global-unset-key (kbd "C-x C-f")) ; find-file (global-unset-key (kbd "C-x d")) ; dired. (use find-file instead) (global-set-key (kbd "M-f") 'find-file) ; was forward-word (global-set-key (kbd "M-F") 'my-find-file-at-point) ; was nil (global-set-key (kbd "M-a") 'execute-extended-command) ; was backward- sentence (global-set-key (kbd "M-A") 'shell-command) i've also modified my ffap so that, when i view web logs which has relative paths based on web root dir (as opposed the real root dir), i can still use ffap to open the right file. (defun my-find-file-at-point () "Same as `find-file-at-point' but prepend path if root file. If the path start with =E2=80=9C/=E2=80=9D and not "/Users/", then prepend i= t with =E2=80=9C~/ web=E2=80=9D." (interactive) (let (ff) (setq ff (thing-at-point 'filename)) (when (and (equal "/" (substring ff 0 1)) (not (equal "/Users/" (substring ff 0 7)))) (setq ff (concat "~/web" ff))) (find-file ff) ) ) I have several emacs tutorial on how to define arbitary keybindings, and a full shortcut set based on ergonomic priciples. It's on my website you might find interesting. Xah xah@xahlee.org =E2=88=91 http://xahlee.org/ =E2=98=84