all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* find-file-noselect
@ 2012-08-30 17:15 drain
  2012-08-30 21:12 ` find-file-noselect Doug Lewan
  2012-08-30 21:14 ` find-file-noselect Doug Lewan
  0 siblings, 2 replies; 4+ messages in thread
From: drain @ 2012-08-30 17:15 UTC (permalink / raw)
  To: Help-gnu-emacs

I want a function that does the same thing, but with the shell, e.g., what
this does to a file: 

(save-excursion
  (let ((foo (get-buffer (find-file-noselect "/home/drain/foo.org"))))
	(set-buffer foo)
	(insert "test operation")))

In case further clarity is necessary:

I want to open a shell buffer, but do not want to select it (so I stay in
the current buffer). Just like the above, but with the shell instead of
foo.org.




--
View this message in context: http://emacs.1067599.n5.nabble.com/find-file-noselect-tp262675.html
Sent from the Emacs - Help mailing list archive at Nabble.com.



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

* RE: find-file-noselect
  2012-08-30 17:15 find-file-noselect drain
@ 2012-08-30 21:12 ` Doug Lewan
  2012-08-30 21:14 ` find-file-noselect Doug Lewan
  1 sibling, 0 replies; 4+ messages in thread
From: Doug Lewan @ 2012-08-30 21:12 UTC (permalink / raw)
  To: drain, Help-gnu-emacs@gnu.org

I'm guessing futher clarity is necessary, if only because there so much to do with processes. 

Looking at the info page for Processes is probably a good place to start understanding what is possible whith shells and other processes. (That's Info Elisp section 37 with emacs 24.)

,Doug

> -----Original Message-----
> From: help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org
> [mailto:help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org] On
> Behalf Of drain
> Sent: Thursday, 2012 August 30 13:15
> To: Help-gnu-emacs@gnu.org
> Subject: find-file-noselect
> 
> I want a function that does the same thing, but with the shell, e.g.,
> what
> this does to a file:
> 
> (save-excursion
>   (let ((foo (get-buffer (find-file-noselect "/home/drain/foo.org"))))
> 	(set-buffer foo)
> 	(insert "test operation")))
> 
> In case further clarity is necessary:
> 
> I want to open a shell buffer, but do not want to select it (so I stay
> in
> the current buffer). Just like the above, but with the shell instead of
> foo.org.
> 
> 
> 
> 
> --
> View this message in context: http://emacs.1067599.n5.nabble.com/find-
> file-noselect-tp262675.html
> Sent from the Emacs - Help mailing list archive at Nabble.com.




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

* RE: find-file-noselect
  2012-08-30 17:15 find-file-noselect drain
  2012-08-30 21:12 ` find-file-noselect Doug Lewan
@ 2012-08-30 21:14 ` Doug Lewan
  1 sibling, 0 replies; 4+ messages in thread
From: Doug Lewan @ 2012-08-30 21:14 UTC (permalink / raw)
  To: drain, Help-gnu-emacs@gnu.org

I'm guessing futher clarity is necessary, if only because there is so much to do with processes. 

Looking at the info page for Processes is probably a good place to start understanding what is possible whith shells and other processes. (That's Info Elisp section 37 with emacs 24.)

,Doug

(Sorry, I accidentally a verb.)

> -----Original Message-----
> From: help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org
> [mailto:help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org] On
> Behalf Of drain
> Sent: Thursday, 2012 August 30 13:15
> To: Help-gnu-emacs@gnu.org
> Subject: find-file-noselect
> 
> I want a function that does the same thing, but with the shell, e.g.,
> what
> this does to a file:
> 
> (save-excursion
>   (let ((foo (get-buffer (find-file-noselect "/home/drain/foo.org"))))
> 	(set-buffer foo)
> 	(insert "test operation")))
> 
> In case further clarity is necessary:
> 
> I want to open a shell buffer, but do not want to select it (so I stay
> in
> the current buffer). Just like the above, but with the shell instead of
> foo.org.
> 
> 
> 
> 
> --
> View this message in context: http://emacs.1067599.n5.nabble.com/find-
> file-noselect-tp262675.html
> Sent from the Emacs - Help mailing list archive at Nabble.com.




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

* Re: find-file-noselect
       [not found] <mailman.7829.1346346933.855.help-gnu-emacs@gnu.org>
@ 2012-08-31  1:48 ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2012-08-31  1:48 UTC (permalink / raw)
  To: help-gnu-emacs

> (save-excursion
>   (let ((foo (get-buffer (find-file-noselect "/home/drain/foo.org"))))
> 	(set-buffer foo)
> 	(insert "test operation")))

To clarify: in the above, find-file-noselect returns a buffer, so
`get-buffer' just returns its argument.  And save-excursion + set-buffer
is better replaced by with-current-buffer.  All in all:

   (with-current-buffer (find-file-noselect "/home/drain/foo.org")
     (insert "test operation"))

> I want to open a shell buffer, but do not want to select it (so I stay in
> the current buffer). Just like the above, but with the shell instead of
> foo.org.

find-file-noselect re-uses an existing buffer (if there is one).  So if
you want the equivalent for a shell-style buffer, you could try

  (with-current-buffer
      (or (get-buffer "*shell*")
          (make-comint-in-buffer "shell" nil "/bin/bash"))
    (unless (derived-mode-p 'comint-mode) (shell-mode))
    (insert "test operation"))


-- Stefan


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

end of thread, other threads:[~2012-08-31  1:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-30 17:15 find-file-noselect drain
2012-08-30 21:12 ` find-file-noselect Doug Lewan
2012-08-30 21:14 ` find-file-noselect Doug Lewan
     [not found] <mailman.7829.1346346933.855.help-gnu-emacs@gnu.org>
2012-08-31  1:48 ` find-file-noselect Stefan Monnier

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.