emacs-orgmode
[Top][All Lists]
Advanced

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

[Orgmode] Re: shortcut keys for mark ups


From: Patrick Drechsler
Subject: [Orgmode] Re: shortcut keys for mark ups
Date: Thu, 08 Jan 2009 00:05:22 +0100
User-agent: Thunderbird 2.0.0.19 (Windows/20081209)

Bernt Hansen schrieb:
Patrick Drechsler <address@hidden> 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





reply via email to

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