emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] inline source code blocks


From: Eric Schulte
Subject: Re: [O] inline source code blocks
Date: Thu, 06 Mar 2014 15:04:05 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Ilya Shlyakhter <address@hidden> writes:

> Some questions about inline source code blocks:
>
>    - They're not fontified even when org-src-fontify-natively is true
> -- correct?

Correct.

> 
>    - They're not included in tangled code; is that intended behavior?
> The manual does not seem to say they're different from normal code
> blocks, except for syntax.

They were originally added for the sole purpose of including results
inline in textual elements.  They are not meant to export code.  There
is currently no support (to my knowledge) for inline fontified code.

>    There are also mailing list messages that suggest they're not meant
> to be exported.   What is the correct understanding?   I can submit a
> patch to the manual once I understand this myself.
>

That would be much appreciated.

>
>   - For very short code snippets (1-2 lines), it would be good to
> allow specifying (via properties) a default language for code blocks
> (say C) and a prefix character (say '>'), after which one could write
>
>     > int i;
>

I think code blocks work well for non-inline code.  Although I think
that an inline fontification solution may be nice.  I use the following
to make code block syntax less intrusive...

Pretty code blocks
#+begin_src emacs-lisp
  (defun prettier-org-code-blocks ()
    (interactive)
    (font-lock-add-keywords nil
      '(("\\(\+begin_src\\)"
         (0 (progn (compose-region (match-beginning 1) (match-end 1) ?¦)
                   nil)))
        ("\\(\+end_src\\)"
         (0 (progn (compose-region (match-beginning 1) (match-end 1) ?¦)
                   nil))))))
  (add-hook 'org-mode-hook 'prettier-org-code-blocks)
#+end_src

and code blocks may easily by typed with "< s TAB".  Beyond that you
could add personal customization to further reduce either the visual or
typing burden.

>
> and have this be the equivalent of
>
> +BEGIN_SRC c
>     int i;
> +END_SRC
>
> by analogy with short literal examples
>    : such as this
>
> Would this break any Org invariants?
>
> (Context: trying to use Org for literate programming in C++;
> interested in others' experience in this area).
>

Hope these suggestions help,

>
> Thanks,
>
> Ilya
>

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D



reply via email to

[Prev in Thread] Current Thread [Next in Thread]