unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Xah <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: opening a filename that appears in a buffer?
Date: Thu, 22 May 2008 09:31:22 -0700 (PDT)	[thread overview]
Message-ID: <ab37a411-ce03-4607-a5dc-194e17728981@g16g2000pri.googlegroups.com> (raw)
In-Reply-To: 01bc057a-47b6-4f3c-9685-648babebe7c3@h1g2000prh.googlegroups.com

On May 20, 12:53 pm, ljp <lonnie.princeho...@gmail.com> 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 “shell” to just “sh”.

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 “/” and not "/Users/", then prepend it with “~/
web”."
 (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
∑ http://xahlee.org/

      parent reply	other threads:[~2008-05-22 16:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-20 19:53 opening a filename that appears in a buffer? ljp
2008-05-20 20:01 ` Sven Joachim
2008-05-20 20:33   ` ljp
2008-05-20 20:04 ` Marc Tfardy
2008-05-20 21:52 ` Richard G Riley
2008-05-22 16:31 ` Xah [this message]

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=ab37a411-ce03-4607-a5dc-194e17728981@g16g2000pri.googlegroups.com \
    --to=xahlee@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /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).