emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rainer M Krug <r.m.krug@gmail.com>
To: Eric Schulte <eric.schulte@gmx.com>
Cc: FengShu <tumashu@gmail.com>,
	emacs-orgmode@gnu.org, "Thomas S. Dye" <tsd@tsdye.com>
Subject: Re: layout org-babel menu WAS: About org-babel menu
Date: Wed, 11 Apr 2012 09:26:58 +0200	[thread overview]
Message-ID: <4F853242.3020600@gmail.com> (raw)
In-Reply-To: <87pqbfhwq0.fsf@gmx.com>

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

On 11/04/12 03:40, Eric Schulte wrote:
> tsd@tsdye.com (Thomas S. Dye) writes:
> 
>> Eric Schulte <eric.schulte@gmx.com> writes:
>> 
>>> Torsten Wagner <torsten.wagner@gmail.com> writes:
>>> 
>>>> Hi,
>>>> 
>>>> for me the biggest "trouble" with babel is to remember the possible keywords in the
>>>> header for different languages. There were a lot of ongoing syntax change which did not
>>>> make it easier for me to remember all this. Thus a menu which is organised by languages
>>>> offering all possible settings for each language would be very helpful. | Python |    | |
>>>> export - code - result - both - none |    | |  tangle - no - yes- filename |   | |
>>>> result - value - output |  | | ... | ...
>>>> 
>>>> Not sure how effectual this would be in a main menu. It would be definitely awesome in a
>>>> context menu
>>>> 
>>>> That would be (copied from worg) [*] indicates cursor position
>>>> 
>>>> #+NAME: factorial #+BEGIN_SRC haskell [*] :results silent :exports code :var n=0
>>>> 
>>>> a context menu would appear presenting all possible header arguments for haskell
>>>> 
>>>> #+NAME: factorial #+BEGIN_SRC haskell :results [*] :exports code :var n=0
>>>> 
>>>> a context menu presenting all possible values for the header argument :results in
>>>> haskell I guess that together with the possibility to call this menu by keyboard strokes
>>>> or alternatively show the same infos in the minibuffer would be a great win for babel and
>>>> it would make many questions here on the list unnecessary. Furthermore, any change or
>>>> extension in the syntax for a certain language would be directly reflected to the
>>>> end-user. E.g., If I suddenly see the menu entry :exports 3dprint, I would be curious
>>>> and check it out on worg and the manual ;)
>>>> 
>>>> Totti
>>>> 
>>> 
>>> Hi,
>>> 
>>> I've put together a first pass at such support for interactive header argument look up.
>>> Please evaluate this elisp code [1] in your *scratch* buffer, then in an Org-mode buffer
>>> insert a code block like the following with the point at [*], and press tab.
>>> 
>>> #+begin_src R :[*] :foo #+end_src
>>> 
>>> You should see an auto-completion list showing which header arguments are available and
>>> (for those with known arguments) which arguments may be specified.  This includes language
>>> specific header arguments, i.e., the R code block above suggests about twice as many
>>> possible header arguments as an elisp block.  Note this "expand on tab after :" behavior is
>>> active on "#+headers:" lines as well.
>>> 
>>> This makes use of the `org-babel-common-header-args-w-values' variable which holds header
>>> argument names and completions, as well as the org-babel-header-arg-names:lang variables.
>>> 
>>> Does this seem like a good interface?
>>> 
>>> Is it missing any important functionality?
>>> 
>>> Best,
>>> 
>>> Footnotes: [1] ;; Add support for completing-read insertion of header arguments after ":" 
>>> (defun org-babel-header-arg-expand () "Call `org-babel-enter-header-arg-w-completion' in
>>> appropriate contexts." (when (and (= (char-before) ?\:)
>>> (org-babel-where-is-src-block-head)) (org-babel-enter-header-arg-w-completion (match-string
>>> 2))))
>>> 
>>> (defun org-babel-enter-header-arg-w-completion (&optional lang) "Insert header argument
>>> appropriate for LANG with completion." (let* ((lang-headers-var (intern (concat
>>> "org-babel-header-arg-names:" lang))) (lang-headers (when (boundp lang-headers-var) (mapcar
>>> #'symbol-name (eval lang-headers-var)))) (headers (append (mapcar #'symbol-name
>>> org-babel-header-arg-names) lang-headers)) (header (org-completing-read "Header Arg: "
>>> headers)) (args (cdr (assoc (intern header) org-babel-common-header-args-w-values))) (arg
>>> (when (and args (listp args)) (org-completing-read (format "%s: " header) (mapcar
>>> #'symbol-name (car args)))))) (insert (concat header " " (or arg ""))) (cons header arg)))
>>> 
>>> (add-hook 'org-tab-first-hook 'org-babel-header-arg-expand)
>> 
>> Hi Eric,
>> 
>> This is potentially much nicer than a function template.  I tried filling out an R source
>> code block's header arguments, but I couldn't find a way to get :results output graphics,
>> which I use frequently for ggplot2 graphics.  With TAB I could see type arguments, but not 
>> collection or handling arguments.  Is there some way to cycle through the various completion
>> lists?
>> 
>> All the best, Tom
> 
> Hi Tom,
> 
> Currently language specific arguments for header arguments are not stored in any elisp
> variables so there is no way to provide this information to the auto completion function.  I'm
> adding a new suite of language-specific variables which may be customized by each language to 
> provide information on language-specific header-argument arguments.
> 
> I've just put together this new code into a patch.  I'm not currently able to run the test
> suite without massive failures (with or without this patch), so I'm just attaching the patch
> here rather than pushing it up directly.  If it works well on other people's systems I think
> it should be committed.

Hi

I applied the patch and it seems to be working when used on #+header: but on
#+src_begin R  :[*]
#+end_src

it folds the code block when tab is pressed at [*]

No detailed further tests done.

Cheers,

Rainer

> 
> After this is applied the language-specific header argument variables will need to be fleshed
> out.  For example see the value of the `org-babel-header-args:R' which includes the "graphics"
> results option. The arguments of these variables will override the arguments of specific 
> headers in the global `org-babel-common-header-args-w-values' variable.
> 
> Best,
> 
> 
> 
> 
> 


- -- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys.
(Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      Rainer@krugs.de

Skype:      RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEUEARECAAYFAk+FMkIACgkQoYgNqgF2egoWEgCePdfvHHIgCNSB8N83oAGdOS8j
EcAAmK5Kl637U2PXGGSoSnfpU+Cn5WQ=
=miy4
-----END PGP SIGNATURE-----

  reply	other threads:[~2012-04-11  7:27 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-19 13:22 About org-babel menu FengShu
2012-03-19 14:22 ` Eric Schulte
2012-03-19 14:41   ` Rainer M Krug
2012-03-19 14:52     ` Eric Schulte
2012-03-31  5:50       ` Torsten Wagner
2012-03-31  7:21         ` Nick Dokos
2012-04-01 16:34           ` Bernt Hansen
2012-04-01 20:26             ` Nick Dokos
2012-03-31  8:27         ` Bastien
2012-03-31 10:33           ` Yagnesh Raghava Yakkala
2012-03-19 15:03     ` Jonathan Leech-Pepin
2012-03-27 23:07     ` Bastien
2012-04-05  9:08       ` layout org-babel menu WAS: " Rainer M Krug
2012-04-05 12:44         ` Eric Schulte
2012-04-06  1:51           ` Torsten Wagner
2012-04-06  6:34             ` Rainer M Krug
2012-04-06  6:48               ` Thorsten
2012-04-06  6:58                 ` Rainer M Krug
2012-04-06  7:18                 ` Bastien
2012-04-06  9:29                   ` Thorsten
2012-04-06 15:40             ` Thomas S. Dye
2012-04-06 21:51             ` Eric Schulte
2012-04-08 21:19               ` Thomas S. Dye
2012-04-11  1:40                 ` Eric Schulte
2012-04-11  7:26                   ` Rainer M Krug [this message]
2012-04-11 13:59                     ` Eric Schulte
2012-04-11 20:12                       ` Thomas S. Dye
2012-04-13 12:45                         ` Eric Schulte
2012-04-13 19:37                           ` [bug?] Re: layout " Yagnesh Raghava Yakkala
2012-04-14 13:35                             ` Eric Schulte
2012-04-14 16:21                               ` Nick Dokos
2012-04-10  8:05               ` layout org-babel menu WAS: About " Rainer M Krug
2012-04-10 20:35                 ` Bastien
2012-04-11  7:10                   ` Rainer M Krug
2012-04-11  7:24                     ` Yagnesh Raghava Yakkala
2012-04-11  8:10                       ` Bastien
2012-04-11  8:11                     ` Bastien
2012-04-11  8:13                       ` Rainer M Krug
2012-04-11 13:51                         ` Eric Schulte
2012-04-11 13:43                       ` Eric Schulte

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.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F853242.3020600@gmail.com \
    --to=r.m.krug@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=eric.schulte@gmx.com \
    --cc=tsd@tsdye.com \
    --cc=tumashu@gmail.com \
    /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.
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).