all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Calling external programs in emacs
@ 2017-01-13 18:53 Sam Nirvana
  2017-01-13 20:46 ` tomas
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Sam Nirvana @ 2017-01-13 18:53 UTC (permalink / raw)
  To: help-gnu-emacs

I'm new to emacs, so forgive my inexperience.

As you know, with Vim I can compile, say, a TeX file from within the 
editor with the following command:

	:!pdftex %

Is there a way to do the same thing with emacs?


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

* Re: Calling external programs in emacs
  2017-01-13 18:53 Calling external programs in emacs Sam Nirvana
@ 2017-01-13 20:46 ` tomas
  2017-01-13 21:25 ` James K. Lowden
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: tomas @ 2017-01-13 20:46 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Jan 13, 2017 at 06:53:42PM +0000, Sam Nirvana wrote:
> I'm new to emacs, so forgive my inexperience.
> 
> As you know, with Vim I can compile, say, a TeX file from within the 
> editor with the following command:
> 
> 	:!pdftex %
> 
> Is there a way to do the same thing with emacs?

Yes. If your buffer is in TeX mode, you can either hit C-c C-f or
go through the menu TeX -> TeX file. You can control which command
is issued by setting the variable "tex-command" (try, when in TeX
mode, hitting C-h C-v, then entering tex-command (TAB autocompletes)
and follow the instructions.

Other modes (C, whatever) have similar compile commands. You get
a new buffer with the compile log; errors have a link to the source
spot, when possible.

For TeX mode, you have shortcuts for opening the DVI file (C-c C-v)
- -- or the PDF file, depending on how you set up things.

Try M-x customize-group RET tex RET and follow the links, to get an
impression on what is there. Ask away when stuck :-)

regards
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlh5PI4ACgkQBcgs9XrR2kaVVgCeMOEIiH6bgznaxIwIEyHMMsHn
BgQAn26yySm50OfpdmKuaVwu4x8S8ua4
=hDWw
-----END PGP SIGNATURE-----



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

* Re: Calling external programs in emacs
  2017-01-13 18:53 Calling external programs in emacs Sam Nirvana
  2017-01-13 20:46 ` tomas
@ 2017-01-13 21:25 ` James K. Lowden
  2017-01-13 21:51   ` Joost Kremers
  2017-01-13 22:34 ` Dan Espen
  2017-01-18  3:40 ` Rusi
  3 siblings, 1 reply; 8+ messages in thread
From: James K. Lowden @ 2017-01-13 21:25 UTC (permalink / raw)
  To: help-gnu-emacs

On Fri, 13 Jan 2017 18:53:42 +0000 (UTC)
Sam Nirvana <samnirvana@linux.org> wrote:

> I'm new to emacs, so forgive my inexperience.
> 
> As you know, with Vim I can compile, say, a TeX file from within the 
> editor with the following command:
> 
> 	:!pdftex %
> 
> Is there a way to do the same thing with emacs?

The emacs function you want is called shell-function.  It's usually
mapped to M-! (meta-bang).  You can verify that with either 

	C-h f shell-function
or
	C-h k M-!

To run asynchronously, see async-shell-function, usually M-&.  

HTH.  

--jkl



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

* Re: Calling external programs in emacs
  2017-01-13 21:25 ` James K. Lowden
@ 2017-01-13 21:51   ` Joost Kremers
  0 siblings, 0 replies; 8+ messages in thread
From: Joost Kremers @ 2017-01-13 21:51 UTC (permalink / raw)
  To: James K. Lowden; +Cc: help-gnu-emacs


On Fri, Jan 13 2017, James K. Lowden wrote:
> On Fri, 13 Jan 2017 18:53:42 +0000 (UTC)
> Sam Nirvana <samnirvana@linux.org> wrote:
>
>> I'm new to emacs, so forgive my inexperience.
>> 
>> As you know, with Vim I can compile, say, a TeX file from 
>> within the 
>> editor with the following command:
>> 
>> 	:!pdftex %
>> 
>> Is there a way to do the same thing with emacs?
>
> The emacs function you want is called shell-function.  It's 
> usually
> mapped to M-! (meta-bang).  You can verify that with either 
>
> 	C-h f shell-function
> or
> 	C-h k M-!
>
> To run asynchronously, see async-shell-function, usually M-&.  

It should perhaps be pointed out that while M-! works to call 
`shell-command', Emacs usually provides some interface to the most 
commond commands you may want to call for a specific file type. So 
running pdftex on a file doesn't require calling M-! and typing 
out the command. Personally, I use AUCTeX (which you should really 
check out if you use TeX or LaTeX), which makes it possible to 
call TeX & friends with C-c C-c. It even tries to guess what 
command you're most likely to execute next. 



-- 
Joost Kremers
Life has its moments



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

* Re: Calling external programs in emacs
  2017-01-13 18:53 Calling external programs in emacs Sam Nirvana
  2017-01-13 20:46 ` tomas
  2017-01-13 21:25 ` James K. Lowden
@ 2017-01-13 22:34 ` Dan Espen
  2017-01-14 11:44   ` Jens Lechtenboerger
  2017-01-18  3:40 ` Rusi
  3 siblings, 1 reply; 8+ messages in thread
From: Dan Espen @ 2017-01-13 22:34 UTC (permalink / raw)
  To: help-gnu-emacs

Sam Nirvana <samnirvana@linux.org> writes:

> I'm new to emacs, so forgive my inexperience.
>
> As you know, with Vim I can compile, say, a TeX file from within the 
> editor with the following command:
>
> 	:!pdftex %
>
> Is there a way to do the same thing with emacs?

That runs a shell command in vi.
Emacs can do that also (M-!),
but for compiling, you want to use the emacs command:

M-x compile

you probably want to bind a key to that.

The main reason you want to do a compile is because the Emacs
functions next-error and previous-error work after a compile.

The M-x command by default runs the command "make -k".
You can just type your command over that.

I highly recommend creating a Makefile.


-- 
Dan Espen


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

* Re: Calling external programs in emacs
  2017-01-13 22:34 ` Dan Espen
@ 2017-01-14 11:44   ` Jens Lechtenboerger
  0 siblings, 0 replies; 8+ messages in thread
From: Jens Lechtenboerger @ 2017-01-14 11:44 UTC (permalink / raw)
  To: help-gnu-emacs

On 2017-01-13, at 17:34, Dan Espen wrote:

> Sam Nirvana <samnirvana@linux.org> writes:
>
>> As you know, with Vim I can compile, say, a TeX file from within the 
>> editor with the following command:
>>
>> 	:!pdftex %
>>
>> Is there a way to do the same thing with emacs?

In addition to the various suggestions for shell commands so far:
If you are looking for an integrated (La)TeX environment, you may
like AUCTeX: https://www.gnu.org/software/auctex/

Best wishes
Jens



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

* Re: Calling external programs in emacs
  2017-01-13 18:53 Calling external programs in emacs Sam Nirvana
                   ` (2 preceding siblings ...)
  2017-01-13 22:34 ` Dan Espen
@ 2017-01-18  3:40 ` Rusi
  2017-01-18 18:21   ` John Mastro
  3 siblings, 1 reply; 8+ messages in thread
From: Rusi @ 2017-01-18  3:40 UTC (permalink / raw)
  To: help-gnu-emacs

On Saturday, January 14, 2017 at 12:23:46 AM UTC+5:30, Sam Nirvana wrote:
> I'm new to emacs, so forgive my inexperience.
> 
> As you know, with Vim I can compile, say, a TeX file from within the 
> editor with the following command:
> 
> 	:!pdftex %
> 
> Is there a way to do the same thing with emacs?

Others have already told you about M-! (also to be found on Menu→Tools→Shell Command)

The % trick however does not work OTB in emacs
Here is some elisp that can help that
https://lists.gnu.org/archive/html/help-gnu-emacs/2008-08/msg00482.html


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

* Re: Calling external programs in emacs
  2017-01-18  3:40 ` Rusi
@ 2017-01-18 18:21   ` John Mastro
  0 siblings, 0 replies; 8+ messages in thread
From: John Mastro @ 2017-01-18 18:21 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Rusi <rustompmody@gmail.com> wrote:
> On Saturday, January 14, 2017 at 12:23:46 AM UTC+5:30, Sam Nirvana wrote:
> > I'm new to emacs, so forgive my inexperience.
> >
> > As you know, with Vim I can compile, say, a TeX file from within the
> > editor with the following command:
> >
> >       :!pdftex %
> >
> > Is there a way to do the same thing with emacs?
>
> Others have already told you about M-! (also to be found on Menu→Tools→Shell Command)
>
> The % trick however does not work OTB in emacs
> Here is some elisp that can help that
> https://lists.gnu.org/archive/html/help-gnu-emacs/2008-08/msg00482.html

Someone may have already mentioned this, but Emacs's built-in way to
achieve something similar is to type `M-! M-n'. The M-n will cause the
relative file name of the current buffer to be inserted, leaving point
before it.

        John



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

end of thread, other threads:[~2017-01-18 18:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-13 18:53 Calling external programs in emacs Sam Nirvana
2017-01-13 20:46 ` tomas
2017-01-13 21:25 ` James K. Lowden
2017-01-13 21:51   ` Joost Kremers
2017-01-13 22:34 ` Dan Espen
2017-01-14 11:44   ` Jens Lechtenboerger
2017-01-18  3:40 ` Rusi
2017-01-18 18:21   ` John Mastro

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.