emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Different listing styles for same babel language?
@ 2017-07-20  1:14 Michael Gauland
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Gauland @ 2017-07-20  1:14 UTC (permalink / raw)
  To: emacs-orgmode

My org documents include lots of source code blocks, in a variety of
languages. I use the listings package to give each language a
distinctive look.

Lately, my work has involved using shell commands on different machines,
as different users. I'd like to give each shell environment (e.g., local
user, normal user on remote host, root on remote host) a different look.
At the moment, I'm doing this by specifying different shells (bash,
dash, sh) for each. This works, especially since I'm not executing the
commands from emacs, so it doesn't matter which shell I specify.

Is there a better way to do this? 

Would anyone else find it useful? I'm happy to  work on the code, if I'm
not the only one who'd use it.

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

* Different listing styles for same babel language?
@ 2017-07-24  0:34 Michael Gauland
  2017-07-24 16:37 ` Charles C. Berry
  2017-07-24 23:54 ` Adam Porter
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Gauland @ 2017-07-24  0:34 UTC (permalink / raw)
  To: emacs-orgmode

My org documents include lots of source code blocks, in a variety of
languages. I use the listings package to give each language a
distinctive look.

Lately, my work has involved using shell commands on different machines,
as different users. I'd like to give each shell environment (e.g., local
user, normal user on remote host, root on remote host) a different look.
At the moment, I'm doing this by specifying different shells (bash,
dash, sh) for each. This works, especially since I'm not executing the
commands from emacs, so it doesn't matter which shell I specify.

Is there a better way to do this? 

Would anyone else find it useful? I'm happy to  work on the code, if I'm
not the only one who'd use it.

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

* Re: Different listing styles for same babel language?
  2017-07-24  0:34 Different listing styles for same babel language? Michael Gauland
@ 2017-07-24 16:37 ` Charles C. Berry
  2017-08-07  1:06   ` Michael Gauland
  2017-07-24 23:54 ` Adam Porter
  1 sibling, 1 reply; 5+ messages in thread
From: Charles C. Berry @ 2017-07-24 16:37 UTC (permalink / raw)
  To: Michael Gauland; +Cc: emacs-orgmode

On Mon, 24 Jul 2017, Michael Gauland wrote:

> My org documents include lots of source code blocks, in a variety of
> languages. I use the listings package to give each language a
> distinctive look.
>
> Lately, my work has involved using shell commands on different machines,
> as different users. I'd like to give each shell environment (e.g., local
> user, normal user on remote host, root on remote host) a different look.
> At the moment, I'm doing this by specifying different shells (bash,
> dash, sh) for each. This works, especially since I'm not executing the
> commands from emacs, so it doesn't matter which shell I specify.
>
> Is there a better way to do this?
>

See

 	(info "(org) Advanced configuration")

and scroll down to "Extending an existing back-end" where you will find 
a template for modifying the output of a src-block.

Assuming you derive your exporter from the latex backend, you want to have 
something like

#+ATTR_LATEX: :lstyle basic
#+BEGIN_SRC shell
   echo "Hello World"
#+END_SRC

in your *.org file and use

(org-export-read-attribute :attr_latex src-block :lstyle)

to grab the "basic" or whatever in setting up the transcoded result.

HTH,

Chuck

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

* Re: Different listing styles for same babel language?
  2017-07-24  0:34 Different listing styles for same babel language? Michael Gauland
  2017-07-24 16:37 ` Charles C. Berry
@ 2017-07-24 23:54 ` Adam Porter
  1 sibling, 0 replies; 5+ messages in thread
From: Adam Porter @ 2017-07-24 23:54 UTC (permalink / raw)
  To: emacs-orgmode

I don't know how to accomplish this, but I'm guessing that, if you wrote
some code to change the style of individual code blocks, lots of people
would find that useful.  :)

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

* Re: Different listing styles for same babel language?
  2017-07-24 16:37 ` Charles C. Berry
@ 2017-08-07  1:06   ` Michael Gauland
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Gauland @ 2017-08-07  1:06 UTC (permalink / raw)
  Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 802 bytes --]

I recently wrote:

>> My org documents include lots of source code blocks, in a variety of
>> languages. I use the listings package to give each language a
>> distinctive look.
>>
>> Lately, my work has involved using shell commands on different machines,
>> as different users. I'd like to give each shell environment (e.g., local
>> user, normal user on remote host, root on remote host) a different look.
>> At the moment, I'm doing this by specifying different shells (bash,
>> dash, sh) for each. This works, especially since I'm not executing the
>> commands from emacs, so it doesn't matter which shell I specify.
>>
>> Is there a better way to do this?
>>
>
I've found that #+ATTR_LATEX: :options language=.... does exactly what I
was looking for. The attached example may be useful to others.

[-- Attachment #2: lstyle-example.org --]
[-- Type: text/plain, Size: 888 bytes --]

#+LATEX_HEADER: \lstset{frame=shadowbox}
#+LATEX_HEADER: \lstdefinelanguage{bash-local}{rulesepcolor=\color{cyan}}
#+LATEX_HEADER: \lstdefinelanguage{bash-remote}{rulesepcolor=\color{yellow}}
#+LATEX_HEADER: \lstdefinelanguage{bash-remote-root}{rulesepcolor=\color{orange}}
#+PROPERTY: header-args :eval never

#+ATTR_LATEX: :options language=bash-local
#+BEGIN_SRC bash :results output :eval ask
  # Run this script on the local host
  # Install the key in the VM:
  ssh-copy-id -i ~/.ssh/vm \
	      -p 3022 user@127.0.0.1 
#+END_SRC

#+RESULTS:

#+ATTR_LATEX: :options language=bash-remote-root
#+BEGIN_SRC bash
  # Run this as root on the remote host
  apt-get update
  apt-get -y install  git 
#+END_SRC

#+ATTR_LATEX: :options language=bash-remote
#+BEGIN_SRC bash :results output :eval ask
  # Run this as a normal user on the remote host
  cd project
  git pull
  make
#+END_SRC


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

end of thread, other threads:[~2017-08-07  1:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-24  0:34 Different listing styles for same babel language? Michael Gauland
2017-07-24 16:37 ` Charles C. Berry
2017-08-07  1:06   ` Michael Gauland
2017-07-24 23:54 ` Adam Porter
  -- strict thread matches above, loose matches on Subject: below --
2017-07-20  1:14 Michael Gauland

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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