emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* shortcut keys for mark ups
@ 2009-01-06 16:35 Xin Shi
  2009-01-06 17:48 ` Bernt Hansen
  2009-01-06 18:24 ` Carsten Dominik
  0 siblings, 2 replies; 10+ messages in thread
From: Xin Shi @ 2009-01-06 16:35 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

In org mode, are there any shortcut keys for typing the following mark-ups?

#+BEGIN_EXAMPLE
#+END_EXAMPLE

Thanks!

Xin

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

* Re: shortcut keys for mark ups
  2009-01-06 16:35 shortcut keys for mark ups Xin Shi
@ 2009-01-06 17:48 ` Bernt Hansen
  2009-01-06 18:50   ` Xin Shi
  2009-01-07 20:27   ` Patrick Drechsler
  2009-01-06 18:24 ` Carsten Dominik
  1 sibling, 2 replies; 10+ messages in thread
From: Bernt Hansen @ 2009-01-06 17:48 UTC (permalink / raw)
  To: Xin Shi; +Cc: emacs-orgmode

Xin Shi <xs32@cornell.edu> writes:

> In org mode, are there any shortcut keys for typing the following mark-ups?
>
> #+BEGIN_EXAMPLE
> #+END_EXAMPLE

Not that I'm aware of.  You can use a function like the following to
achieve this - or maybe you can use yasnippets (I've never tried that
yet)

------------------------------------------------------------------------
(defun bth-begin-example ()
  (interactive)
  (save-excursion
    (beginning-of-line)
    (insert "#+BEGIN_EXAMPLE\n")
    (end-of-line)
    (insert "\n#+END_EXAMPLE")))


(global-set-key (kbd "<f9> e") 'bth-begin-example)
------------------------------------------------------------------------

Then you can just type <f9> e while on a line and it'll put the EXAMPLE
block around the current line.

HTH,

-Bernt

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

* Re: shortcut keys for mark ups
  2009-01-06 16:35 shortcut keys for mark ups Xin Shi
  2009-01-06 17:48 ` Bernt Hansen
@ 2009-01-06 18:24 ` Carsten Dominik
  2009-01-06 18:47   ` Xin Shi
  1 sibling, 1 reply; 10+ messages in thread
From: Carsten Dominik @ 2009-01-06 18:24 UTC (permalink / raw)
  To: Xin Shi; +Cc: emacs-orgmode


Hi Xin,

there is only an undocumented way to do this:

On an empty line, insert "<e" and then type TAB.

See org-structure-template-alist for a configurable list of similar  
templates.

HTH

- Carsten


On Jan 6, 2009, at 5:35 PM, Xin Shi wrote:

> Hello,
>
> In org mode, are there any shortcut keys for typing the following  
> mark-ups?
>
> #+BEGIN_EXAMPLE
> #+END_EXAMPLE
>
> Thanks!
>
> Xin
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: shortcut keys for mark ups
  2009-01-06 18:24 ` Carsten Dominik
@ 2009-01-06 18:47   ` Xin Shi
  0 siblings, 0 replies; 10+ messages in thread
From: Xin Shi @ 2009-01-06 18:47 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

Hi Carsten,

That's cool! I think it'll be great to document them on the org-manual.

Xin


Carsten Dominik wrote:
>
> Hi Xin,
>
> there is only an undocumented way to do this:
>
> On an empty line, insert "<e" and then type TAB.
>
> See org-structure-template-alist for a configurable list of similar 
> templates.
>
> HTH
>
> - Carsten
>
>
> On Jan 6, 2009, at 5:35 PM, Xin Shi wrote:
>
>> Hello,
>>
>> In org mode, are there any shortcut keys for typing the following 
>> mark-ups?
>>
>> #+BEGIN_EXAMPLE
>> #+END_EXAMPLE
>>
>> Thanks!
>>
>> Xin
>>
>>
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Remember: use `Reply All' to send replies to the list.
>> Emacs-orgmode@gnu.org
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>

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

* Re: shortcut keys for mark ups
  2009-01-06 17:48 ` Bernt Hansen
@ 2009-01-06 18:50   ` Xin Shi
  2009-01-06 19:00     ` Carsten Dominik
  2009-01-06 19:25     ` Richard Riley
  2009-01-07 20:27   ` Patrick Drechsler
  1 sibling, 2 replies; 10+ messages in thread
From: Xin Shi @ 2009-01-06 18:50 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode

Hi Bernt,

Thanks for your reply! That's what I was trying to do. But I think 
Carsten's suggestion of using the "org-structure-template-alist" is more 
appealing to general user.

Xin


Bernt Hansen wrote:
> Xin Shi <xs32@cornell.edu> writes:
>
>   
>> In org mode, are there any shortcut keys for typing the following mark-ups?
>>
>> #+BEGIN_EXAMPLE
>> #+END_EXAMPLE
>>     
>
> Not that I'm aware of.  You can use a function like the following to
> achieve this - or maybe you can use yasnippets (I've never tried that
> yet)
>
> ------------------------------------------------------------------------
> (defun bth-begin-example ()
>   (interactive)
>   (save-excursion
>     (beginning-of-line)
>     (insert "#+BEGIN_EXAMPLE\n")
>     (end-of-line)
>     (insert "\n#+END_EXAMPLE")))
>
>
> (global-set-key (kbd "<f9> e") 'bth-begin-example)
> ------------------------------------------------------------------------
>
> Then you can just type <f9> e while on a line and it'll put the EXAMPLE
> block around the current line.
>
> HTH,
>
> -Bernt
>   

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

* Re: Re: shortcut keys for mark ups
  2009-01-06 18:50   ` Xin Shi
@ 2009-01-06 19:00     ` Carsten Dominik
  2009-01-06 19:25     ` Richard Riley
  1 sibling, 0 replies; 10+ messages in thread
From: Carsten Dominik @ 2009-01-06 19:00 UTC (permalink / raw)
  To: Xin Shi; +Cc: Bernt Hansen, emacs-orgmode


On Jan 6, 2009, at 7:50 PM, Xin Shi wrote:

> Hi Bernt,
>
> Thanks for your reply! That's what I was trying to do. But I think  
> Carsten's suggestion of using the "org-structure-template-alist" is  
> more appealing to general user.

I do like thought that Bernt puts his template around the current  
line.....

- Carsten

>
>
> Xin
>
>
> Bernt Hansen wrote:
>> Xin Shi <xs32@cornell.edu> writes:
>>
>>
>>> In org mode, are there any shortcut keys for typing the following  
>>> mark-ups?
>>>
>>> #+BEGIN_EXAMPLE
>>> #+END_EXAMPLE
>>>
>>
>> Not that I'm aware of.  You can use a function like the following to
>> achieve this - or maybe you can use yasnippets (I've never tried that
>> yet)
>>
>> ------------------------------------------------------------------------
>> (defun bth-begin-example ()
>>  (interactive)
>>  (save-excursion
>>    (beginning-of-line)
>>    (insert "#+BEGIN_EXAMPLE\n")
>>    (end-of-line)
>>    (insert "\n#+END_EXAMPLE")))
>>
>>
>> (global-set-key (kbd "<f9> e") 'bth-begin-example)
>> ------------------------------------------------------------------------
>>
>> Then you can just type <f9> e while on a line and it'll put the  
>> EXAMPLE
>> block around the current line.
>>
>> HTH,
>>
>> -Bernt
>>
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Re: shortcut keys for mark ups
  2009-01-06 18:50   ` Xin Shi
  2009-01-06 19:00     ` Carsten Dominik
@ 2009-01-06 19:25     ` Richard Riley
  1 sibling, 0 replies; 10+ messages in thread
From: Richard Riley @ 2009-01-06 19:25 UTC (permalink / raw)
  To: Xin Shi; +Cc: Bernt Hansen, emacs-orgmode


Or use the org-mode map rather than global key

(define-key org-mode-map  (kbd "C-<f9>") '(lambda()(interactive)(insert "#+BEGIN_EXAMPLE\n\n#+END_EXAMPLE")(previous-line)))


Xin Shi <xs32@cornell.edu> writes:

> Hi Bernt,
>
> Thanks for your reply! That's what I was trying to do. But I think
> Carsten's suggestion of using the "org-structure-template-alist" is
> more appealing to general user.
>
> Xin
>
>
> Bernt Hansen wrote:
>> Xin Shi <xs32@cornell.edu> writes:
>>
>>   
>>> In org mode, are there any shortcut keys for typing the following mark-ups?
>>>
>>> #+BEGIN_EXAMPLE
>>> #+END_EXAMPLE
>>>     
>>
>> Not that I'm aware of.  You can use a function like the following to
>> achieve this - or maybe you can use yasnippets (I've never tried that
>> yet)
>>
>> ------------------------------------------------------------------------
>> (defun bth-begin-example ()
>>   (interactive)
>>   (save-excursion
>>     (beginning-of-line)
>>     (insert "#+BEGIN_EXAMPLE\n")
>>     (end-of-line)
>>     (insert "\n#+END_EXAMPLE")))
>>
>>
>> (global-set-key (kbd "<f9> e") 'bth-begin-example)
>> ------------------------------------------------------------------------
>>
>> Then you can just type <f9> e while on a line and it'll put the EXAMPLE
>> block around the current line.
>>
>> HTH,
>>
>> -Bernt
>>   
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

-- 
 important and urgent problems of the technology of today are no longer the satisfactions of the primary needs or of archetypal wishes, but the reparation of the evils and damages by the technology of yesterday.  ~Dennis Gabor, Innovations:  Scientific, Technological and Social, 1970

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

* Re: shortcut keys for mark ups
  2009-01-06 17:48 ` Bernt Hansen
  2009-01-06 18:50   ` Xin Shi
@ 2009-01-07 20:27   ` Patrick Drechsler
  2009-01-07 22:16     ` Bernt Hansen
  1 sibling, 1 reply; 10+ messages in thread
From: Patrick Drechsler @ 2009-01-07 20:27 UTC (permalink / raw)
  To: emacs-orgmode

Bernt Hansen schrieb:
[snipped nice code]

How can I extend this function to wrap the current selection into a

#+BEGIN_SRC
...code...
#+END_SRC

string while also interactively asking the user for a language string?

-----------------------------------------------------------------
;;  ============================================================
;; Puts current selection between #+BEGIN_SRC and #+END_SRC
;; and ask for language
;;  ============================================================
;; TODO:
;;  1. Retrieve beginning (C-SPACE) and
;;     end of selection (current position)
;;  2. Ask for language and insert that string
;;     after `#+BEGIN_SRC '
(defun my-wrap-src ()
   (interactive)
   (save-excursion
     (beginning-of-line)
     (insert "#+BEGIN_SRC\n")
     (end-of-line)
     (insert "\n#+END_SRC")))
(define-key org-mode-map (kbd "<f9> s") 'my-wrap-src)
-----------------------------------------------------------------

Example org code before function call:

-----------------------------------------------------------------
* Sample Code
public class Bla {
	public static void main(String[] args) {
		System.out.println("Hello");
	}
}
-----------------------------------------------------------------

With the code above:

- Mark the region: C-SPACE on the letter `p' of the string `public' and 
moving the cursor behind the last closing curly bracket.

- String after being asked for a language: `java'

Example org code after function call:

-----------------------------------------------------------------
* Sample Code
#+BEGIN_SRC java
public class Bla {
	public static void main(String[] args) {
		System.out.println("Hello");
	}
}
#+END_SRC
-----------------------------------------------------------------

TIA,

Patrick

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

* Re: shortcut keys for mark ups
  2009-01-07 20:27   ` Patrick Drechsler
@ 2009-01-07 22:16     ` Bernt Hansen
  2009-01-07 23:05       ` Patrick Drechsler
  0 siblings, 1 reply; 10+ messages in thread
From: Bernt Hansen @ 2009-01-07 22:16 UTC (permalink / raw)
  To: Patrick Drechsler; +Cc: emacs-orgmode

Patrick Drechsler <patrick@pdrechsler.de> writes:

> Bernt Hansen schrieb:
> [snipped nice code]
>
> How can I extend this function to wrap the current selection into a
>
> #+BEGIN_SRC
> ...code...
> #+END_SRC
>
> string while also interactively asking the user for a language string?
>
> -----------------------------------------------------------------
> ;;  ============================================================
> ;; Puts current selection between #+BEGIN_SRC and #+END_SRC
> ;; and ask for language
> ;;  ============================================================
> ;; TODO:
> ;;  1. Retrieve beginning (C-SPACE) and
> ;;     end of selection (current position)
> ;;  2. Ask for language and insert that string
> ;;     after `#+BEGIN_SRC '
> (defun my-wrap-src ()
>   (interactive)
>   (save-excursion
>     (beginning-of-line)
>     (insert "#+BEGIN_SRC\n")
>     (end-of-line)
>     (insert "\n#+END_SRC")))
> (define-key org-mode-map (kbd "<f9> s") 'my-wrap-src)
> -----------------------------------------------------------------
>
> Example org code before function call:
>
> -----------------------------------------------------------------
> * Sample Code
> public class Bla {
> 	public static void main(String[] args) {
> 		System.out.println("Hello");
> 	}
> }
> -----------------------------------------------------------------
>
> With the code above:
>
> - Mark the region: C-SPACE on the letter `p' of the string `public'
> and moving the cursor behind the last closing curly bracket.
>
> - String after being asked for a language: `java'
>
> Example org code after function call:
>
> -----------------------------------------------------------------
> * Sample Code
> #+BEGIN_SRC java
> public class Bla {
> 	public static void main(String[] args) {
> 		System.out.println("Hello");
> 	}
> }
> #+END_SRC
> -----------------------------------------------------------------

Something like this maybe?  It's not 100% to spec. I find regions that
are entire lines easier to work with so the end point would be the
beginning of the first line not in the region (not after the })
For me - triple clicking and dragging selects entire lines which works
well for this.

------------------------------------------------------------------------
(defun my-wrap-src ()
  (interactive)
  (let ((beg (region-beginning))
	(end (region-end))
	(src (read-from-minibuffer "Source type: " "java")))
    (save-excursion
      (goto-char (region-end))
      (insert "#+END_SRC\n")
      (goto-char (region-beginning))
      (insert "#+BEGIN_SRC " src "\n"))))
------------------------------------------------------------------------

If you want your behaviour you probably jsut have to change 
      (insert "#+END_SRC\n")
to
      (insert "\n#+END_SRC")
but that's untested.

HTH,
-Bernt

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

* Re: shortcut keys for mark ups
  2009-01-07 22:16     ` Bernt Hansen
@ 2009-01-07 23:05       ` Patrick Drechsler
  0 siblings, 0 replies; 10+ messages in thread
From: Patrick Drechsler @ 2009-01-07 23:05 UTC (permalink / raw)
  To: emacs-orgmode

Bernt Hansen schrieb:
> Patrick Drechsler <patrick@pdrechsler.de> writes:
> 
>> Bernt Hansen schrieb:
>> [snipped nice code]
>> How can I extend this function to wrap the current selection into a
>>
>> #+BEGIN_SRC
>> ...code...
>> #+END_SRC
>>
>> string while also interactively asking the user for a language string?

> Something like this maybe?  It's not 100% to spec. I find regions that
> are entire lines easier to work with so the end point would be the
> beginning of the first line not in the region (not after the })
> For me - triple clicking and dragging selects entire lines which works
> well for this.
> 
> ------------------------------------------------------------------------
> (defun my-wrap-src ()
>   (interactive)
>   (let ((beg (region-beginning))
> 	(end (region-end))
> 	(src (read-from-minibuffer "Source type: " "java")))
>     (save-excursion
>       (goto-char (region-end))
>       (insert "#+END_SRC\n")
>       (goto-char (region-beginning))
>       (insert "#+BEGIN_SRC " src "\n"))))
> ------------------------------------------------------------------------

Wonderful! Thank you very much, it works like a charm! And your analysis 
of my sloppy specs was also correct.

Thank you,

Patrick

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

end of thread, other threads:[~2009-01-07 23:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-06 16:35 shortcut keys for mark ups Xin Shi
2009-01-06 17:48 ` Bernt Hansen
2009-01-06 18:50   ` Xin Shi
2009-01-06 19:00     ` Carsten Dominik
2009-01-06 19:25     ` Richard Riley
2009-01-07 20:27   ` Patrick Drechsler
2009-01-07 22:16     ` Bernt Hansen
2009-01-07 23:05       ` Patrick Drechsler
2009-01-06 18:24 ` Carsten Dominik
2009-01-06 18:47   ` Xin Shi

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