all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* opening a filename that appears in a buffer?
@ 2008-05-20 19:53 ljp
  2008-05-20 20:01 ` Sven Joachim
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: ljp @ 2008-05-20 19:53 UTC (permalink / raw)
  To: help-gnu-emacs

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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: opening a filename that appears in a buffer?
  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
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Sven Joachim @ 2008-05-20 20:01 UTC (permalink / raw)
  To: help-gnu-emacs

On 2008-05-20 21:53 +0200, ljp wrote:

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

Yes, try M-x ffap, it does exactly what you want.

> Thanks!  I've looked through documentation, but I haven't found
> anything like this.

Just look for ffap in the Emacs manual.  Your desire is so common that
there is even a minor mode which redefines the standard bindings for
finding files.

Enjoy,
      Sven


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: opening a filename that appears in a buffer?
  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:04 ` Marc Tfardy
  2008-05-20 21:52 ` Richard G Riley
  2008-05-22 16:31 ` Xah
  3 siblings, 0 replies; 6+ messages in thread
From: Marc Tfardy @ 2008-05-20 20:04 UTC (permalink / raw)
  To: help-gnu-emacs

ljp schrieb:
> 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?

Yes, there is an easier way: ffap = find-file-at-point.

regards

Marc




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: opening a filename that appears in a buffer?
  2008-05-20 20:01 ` Sven Joachim
@ 2008-05-20 20:33   ` ljp
  0 siblings, 0 replies; 6+ messages in thread
From: ljp @ 2008-05-20 20:33 UTC (permalink / raw)
  To: help-gnu-emacs

On May 20, 4:01 pm, Sven Joachim <svenj...@gmx.de> wrote:
> On 2008-05-20 21:53 +0200, ljp wrote:
>
> > 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?
>
> Yes, try M-x ffap, it does exactly what you want.
>
> > Thanks!  I've looked through documentation, but I haven't found
> > anything like this.
>
> Just look for ffap in the Emacs manual.  Your desire is so common that
> there is even a minor mode which redefines the standard bindings for
> finding files.
>
> Enjoy,
>       Sven


Perfect!  Thanks!


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: opening a filename that appears in a buffer?
  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:04 ` Marc Tfardy
@ 2008-05-20 21:52 ` Richard G Riley
  2008-05-22 16:31 ` Xah
  3 siblings, 0 replies; 6+ messages in thread
From: Richard G Riley @ 2008-05-20 21:52 UTC (permalink / raw)
  To: help-gnu-emacs

ljp <lonnie.princehouse@gmail.com> writes:

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

directly from my .emacs and its been there for a while so I dont know if
its the best way:

;; open file/url at point
(require 'ffap)
(ffap-bindings)
(add-to-list 'ffap-c-path "/usr/src/linux/include")
(add-to-list 'ffap-c-path "/usr/src/linux/include/linux")
(add-to-list 'ffap-c-path "/usr/include")
(add-to-list 'ffap-c-path "/usr/include/gtk-2.0")



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: opening a filename that appears in a buffer?
  2008-05-20 19:53 opening a filename that appears in a buffer? ljp
                   ` (2 preceding siblings ...)
  2008-05-20 21:52 ` Richard G Riley
@ 2008-05-22 16:31 ` Xah
  3 siblings, 0 replies; 6+ messages in thread
From: Xah @ 2008-05-22 16:31 UTC (permalink / raw)
  To: help-gnu-emacs

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/^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-05-22 16:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

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.