emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* default headers for source code blocks
@ 2014-09-09 17:24 Subhan Michael Tindall
  2014-09-09 17:44 ` Ista Zahn
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Subhan Michael Tindall @ 2014-09-09 17:24 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org


[-- Attachment #1.1: Type: text/plain, Size: 1446 bytes --]

My apologies if this is in TFM, but I can't seem to find it after substantial digging.
I'm using a lot of source code blocks lately.
What I'd like is a way to specify a set of default headers to insert when a new block is created.
Right now:
C-c C-v d sql RET
#+begin_src sql
#+end_src

What I want is this:
C-c C-v d sql RET
#+begin_src sql  :exports code :tangle yes :comments noweb
#+end_src

Is there a configuration variable I can set for this?  All I can find is refs to see source language documentation, but nothing that actually indicates if/how to manage it.

Thanks,


Subhan Michael Tindall
Program Analyst - FamilyCare Health Plans
825 NE Multnomah St, Suite 1400; Portland OR 97232
Direct: 503-471-3127
Fax:      503-471-3177
Email:  subhant@familycareinc.org<mailto:subhant@familycareinc.org>
[Email-Signature-Logos June 20143]


This message is intended for the sole use of the individual and entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you are not the intended addressee, nor authorized to receive for the intended addressee, you are hereby notified that you may not use, copy, disclose or distribute to anyone the message or any information contained in the message. If you have received this message in error, please immediately advise the sender by reply email and delete the message.  Thank you.

[-- Attachment #1.2: Type: text/html, Size: 5218 bytes --]

[-- Attachment #2: image001.jpg --]
[-- Type: image/jpeg, Size: 30469 bytes --]

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

* Re: default headers for source code blocks
  2014-09-09 17:24 default headers for source code blocks Subhan Michael Tindall
@ 2014-09-09 17:44 ` Ista Zahn
  2014-09-09 19:11 ` Thorsten Jolitz
  2014-09-10  4:24 ` Ken Mankoff
  2 siblings, 0 replies; 5+ messages in thread
From: Ista Zahn @ 2014-09-09 17:44 UTC (permalink / raw)
  To: Subhan Michael Tindall; +Cc: emacs-orgmode@gnu.org

Hi Subhan,

I think the idea is that you should not set his on each individual
block, but set global values. For example

#+PROPERTY: header-args:sql  :exports code :tangle yes :comments noweb

Best,
Ista

On Tue, Sep 9, 2014 at 1:24 PM, Subhan Michael Tindall
<SubhanT@familycareinc.org> wrote:
> My apologies if this is in TFM, but I can’t seem to find it after
> substantial digging.
>
> I’m using a lot of source code blocks lately.
>
> What I’d like is a way to specify a set of default headers to insert when a
> new block is created.
>
> Right now:
>
> C-c C-v d sql RET
>
> #+begin_src sql
>
> #+end_src
>
>
>
> What I want is this:
>
> C-c C-v d sql RET
>
> #+begin_src sql  :exports code :tangle yes :comments noweb
>
> #+end_src
>
>
>
> Is there a configuration variable I can set for this?  All I can find is
> refs to see source language documentation, but nothing that actually
> indicates if/how to manage it.
>
>
>
> Thanks,
>
>
>
>
>
> Subhan Michael Tindall
>
> Program Analyst – FamilyCare Health Plans
>
> 825 NE Multnomah St, Suite 1400; Portland OR 97232
>
> Direct: 503-471-3127
>
> Fax:      503-471-3177
>
> Email:  subhant@familycareinc.org
>
>
>
>
> This message is intended for the sole use of the individual and entity to
> which it is addressed and may contain information that is privileged,
> confidential and exempt from disclosure under applicable law. If you are not
> the intended addressee, nor authorized to receive for the intended
> addressee, you are hereby notified that you may not use, copy, disclose or
> distribute to anyone the message or any information contained in the
> message. If you have received this message in error, please immediately
> advise the sender by reply email and delete the message.  Thank you.

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

* Re: default headers for source code blocks
  2014-09-09 17:24 default headers for source code blocks Subhan Michael Tindall
  2014-09-09 17:44 ` Ista Zahn
@ 2014-09-09 19:11 ` Thorsten Jolitz
  2014-09-10  4:24 ` Ken Mankoff
  2 siblings, 0 replies; 5+ messages in thread
From: Thorsten Jolitz @ 2014-09-09 19:11 UTC (permalink / raw)
  To: emacs-orgmode

Subhan Michael Tindall <SubhanT@familycareinc.org> writes:

> My apologies if this is in TFM, but I can’t seem to find it after
> substantial digging.
>
> I’m using a lot of source code blocks lately.
>
> What I’d like is a way to specify a set of default headers to insert
> when a new block is created.

I have written an 'all-inclusive' function for this case
(https://github.com/tj64/org-dp), it handles all kinds of blocks, all
kinds of header-args including affiliated keywords, knows how to insert
empty blocks, wrap sexps or regions (between lines or marked), how
to 'unwrap' a src-block and how to convert one type of block into
another reusing its contents/parts:

,----[ C-h f org-dp-wrap-in-block RET ]
| org-dp-wrap-in-block is an interactive Lisp function in
| `org-dp-lib.el'.
| 
| (org-dp-wrap-in-block &optional LINES USER-INFO &rest PROMPT-SPEC)
| 
| Wrap sexp-at-point or region in Org block.
| 
| A region instead of the sexp-at-point is wrapped if either
| 
|    - optional arg LINES is an (positive or negative) integer or
| 
|    - the region is active
| 
| In the first case the region is determined by moving LINES lines
| up (LINES is positive) or down (LINES is negative) from point
| using `forward-line', in the second case the active region is
| used.
| 
| If point is already inside of a block, modify it or unwrap its
| content/value instead of wrapping it in another block, except if
| explicitly asked for by user.
| 
| If USER-INFO is given, it should be a list in the format returned
| by `org-dp-prompt', i.e.
| 
|  (elem-type contents replace affiliated args)
| 
| Look up that function's docstring for more information about the
| list's elements. A non-nil USER-INFO suppresses calls to
| `org-dp-prompt' and is used instead of its return value.
| 
| Possible &rest PROMPT-SPEC should be keyword/value pairs used for
| restricting user-prompting via `org-dp-prompt', e.g.
| 
|   :noprompt-affiliated t :noprompt-replace t
| 
| see the docstring of that function for more info.
`----

It is possible (and easy) to define new utility functions by restricting
this very generic function to special use cases, e.g. from my init.el:

#+BEGIN_SRC emacs-lisp
;; *** Org DP

(when (require 'org-dp-lib nil t)
  (defun tj/wrap-in-elisp-block ()
    (org-dp-wrap-in-block
     nil '(src-block nil nil nil
		     (:language "emacs-lisp"
				:preserve-indent 1))))

  (global-set-key (kbd "C-c w w") 'org-dp-wrap-in-block)

  (global-set-key (kbd "C-c w l")
		  (lambda ()
		    (interactive)
		    (let ((current-prefix-arg '(4)))
		      (call-interactively
		       'org-dp-wrap-in-block))))

  (global-set-key (kbd "C-c w e")
		  (lambda ()
		    (interactive)
		    (tj/wrap-in-elisp-block)))

  (global-set-key (kbd "C-c w a")
		  (lambda ()
		    (interactive)
		    (backward-sexp)
		    (tj/wrap-in-elisp-block))) )

#+END_SRC

I you tell me exactly what you need I could write you an utility
function, or maybe play around with the function yourself, its very
powerfull. 

-- 
cheers,
Thorsten

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

* Re: default headers for source code blocks
  2014-09-09 17:24 default headers for source code blocks Subhan Michael Tindall
  2014-09-09 17:44 ` Ista Zahn
  2014-09-09 19:11 ` Thorsten Jolitz
@ 2014-09-10  4:24 ` Ken Mankoff
  2014-09-10  7:31   ` Sebastien Vauban
  2 siblings, 1 reply; 5+ messages in thread
From: Ken Mankoff @ 2014-09-10  4:24 UTC (permalink / raw)
  To: Subhan Michael Tindall; +Cc: emacs-orgmode@gnu.org

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

What about custom template expansions?

http://nicholasvanhorn.com/2014/04/07/org-structure-completion/

Advantage: your C-c C-v d sql RET becomes only <sql TAB. 

Please excuse brevity. Sent from pocket computer with tiny non-haptic feedback keyboard. 

> On Sep 9, 2014, at 13:24, Subhan Michael Tindall <SubhanT@familycareinc.org> wrote:
> 
> My apologies if this is in TFM, but I can’t seem to find it after substantial digging.
> I’m using a lot of source code blocks lately.
> What I’d like is a way to specify a set of default headers to insert when a new block is created.
> Right now:
> C-c C-v d sql RET
> #+begin_src sql
> #+end_src
>  
> What I want is this:
> C-c C-v d sql RET
> #+begin_src sql  :exports code :tangle yes :comments noweb
> #+end_src
>  
> Is there a configuration variable I can set for this?  All I can find is refs to see source language documentation, but nothing that actually indicates if/how to manage it.
>  
> Thanks,
>  
>  
> Subhan Michael Tindall
> Program Analyst – FamilyCare Health Plans
> 825 NE Multnomah St, Suite 1400; Portland OR 97232
> Direct: 503-471-3127
> Fax:      503-471-3177
> Email:  subhant@familycareinc.org
> <image001.jpg>
>  
> 
> This message is intended for the sole use of the individual and entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you are not the intended addressee, nor authorized to receive for the intended addressee, you are hereby notified that you may not use, copy, disclose or distribute to anyone the message or any information contained in the message. If you have received this message in error, please immediately advise the sender by reply email and delete the message.  Thank you.

[-- Attachment #2: Type: text/html, Size: 5541 bytes --]

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

* Re: default headers for source code blocks
  2014-09-10  4:24 ` Ken Mankoff
@ 2014-09-10  7:31   ` Sebastien Vauban
  0 siblings, 0 replies; 5+ messages in thread
From: Sebastien Vauban @ 2014-09-10  7:31 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Ken Mankoff wrote:
> What about custom template expansions?
>
> http://nicholasvanhorn.com/2014/04/07/org-structure-completion/
>
> Advantage: your C-c C-v d sql RET becomes only <sql TAB.

And the last (?) solution is YASnippet: create your skeleton, and bind
it to whatever ("sql <TAB>", for example -- even shorter, of one key
stroke, than the easy template ;-)).

Best regards,
  Seb

-- 
Sebastien Vauban

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

end of thread, other threads:[~2014-09-10  7:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-09 17:24 default headers for source code blocks Subhan Michael Tindall
2014-09-09 17:44 ` Ista Zahn
2014-09-09 19:11 ` Thorsten Jolitz
2014-09-10  4:24 ` Ken Mankoff
2014-09-10  7:31   ` Sebastien Vauban

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