emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Xebar Saram <zeltakc@gmail.com>
To: Thorsten Jolitz <tjolitz@gmail.com>
Cc: org mode <emacs-orgmode@gnu.org>
Subject: Re: [ANN] org-dp-wrap-in-block
Date: Sat, 7 Mar 2015 08:37:09 +0200	[thread overview]
Message-ID: <CAOQHXPrZhEmbwXYJ4mn_PvjiOnX-=NKEkeX4EHwHGzWJd_XJ_w@mail.gmail.com> (raw)
In-Reply-To: <87k364e07m.fsf@gmail.com>

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

H Thorsten

i know this is a *very* late response but life/work has dragged me in last
few months and only now i have time to take a look at org-dp :)

if you remember i have near to null coding skills but i am trying to make
sense of stuff looking at the github site and the org-dp.el examples

i understand (or at least i think i do) that org-dp is very complex and
covers not just wrapping in source code lines/areas but what i basically
need is to assign hotkeys to specific wrapping. mainly these:

1. a hotkey to quick wrap in language X a line
2. a hotkey to quick wrap in language X y lines
3. a hotkey to quick wrap in language X a selection

any tips and how to start/create these keybinds? is there a more
comprehensive documentation on org-dp somewhere else i may have overlooked?

thx alot!

z




On Tue, Aug 19, 2014 at 10:41 PM, Thorsten Jolitz <tjolitz@gmail.com> wrote:

> Xebar Saram <zeltakc@gmail.com> writes:
>
> Hi,
>
> > will use it over the next few days and report bug (if any) that i find
>
> good, thanks.
>
> As a hint, here the global keybindings I defined in my init.el (my
> default use-case is to simply wrap in a plain emacs-lisp src-block).
>
> You can define all kinds of functions that don't prompt the user anymore
> by giving a list like
>
>  '(elem-type contents replace affiliated args)
>
> as second arg to `org-dp-wrap-in-block', and in that list you can
> specify any kind of customized block.
>
> #+BEGIN_SRC emacs-lisp
> (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"))))
>
>   (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)
>                     (beginning-of-line)
>                     (tj/wrap-in-elisp-block)))
>
>   (global-set-key (kbd "C-c w a")
>                   (lambda ()
>                     (interactive)
>                     (backward-sexp)
>                     (beginning-of-line)
>                     (tj/wrap-in-elisp-block))) )
> #+END_SRC
>
>
> > On Tue, Aug 19, 2014 at 5:14 PM, Thorsten Jolitz <tjolitz@gmail.com>
> > wrote:
> >
> >     Hi List,
> >
> >     I've written the "eierlegende Wollmilchsau" of wrap-in-block
> >     functions
> >     (i.e. the 'all-inclusive mother of all wrap-in-block functions').
> >
> >     To check it out, you need to
> >     1. Clone or fork the git repo (https://github.com/tj64/org-dp)
> >     2. (add-to-list 'load-path "/path/to/org-dp/") and
> >     3. (require 'org-dp-lib') in your init file
> >
> >     `org-dp-wrap-in-block' works on/with all kinds of Org blocks, and
> >     can be
> >     called interactively or non-interactively.
> >
> >     It
> >
> >     - inserts a new block when called on an empty line without
> >     arguments
> >
> >     - wraps sexp or region or '+/- X lines from point' into a newly
> >     created
> >     block
> >
> >     - when called with point inside a block, it either
> >
> >     + unwraps the blocks content, i.e. deletes the surrounding block
> >     or
> >
> >     + replaces the surrounding block with a different block
> >
> >     It takes full account of affiliated keywords. In case of
> >     src-blocks,
> >     it puts src-block parameters on the block's headline, but with
> >     `org-dp-toggle-headers' its easy to toggle between parameters
> >
> >     ,----
> >     | #+begin_src R :noweb yes
> >     `----
> >
> >     and headers
> >
> >     ,----
> >     | #+header: :noweb yes
> >     | #+begin_src R
> >     `----
> >
> >     This function takes into account so many options that
> >     combinatorics hits
> >     you badly when trying to test all of them. Everything I tried
> >     works now
> >     with the current version, but its not unlikely that daily usage
> >     will
> >     discover some bugs or untreated corner cases. Please report them
> >     with
> >     backtrace.
> >
> >     The good news is that besides its complexity, its not one
> >     mega-convoluted monolithic function for a single task only.
> >     Instead I
> >     outfactored the core functionality into the 'org-dp.el' library
> >     ("Declarative Programming with Org Elements") which offers
> >     potentially
> >     massive time (and headache) savings when programming with Org
> >     Elements
> >     on the local level.
> >
> >     'org-dp' acts on the internal representation of Org elements, and
> >     due to
> >     the total uniformity of this representation it is possible to do
> >     diverse
> >     actions on diverse elements in a very uniform way, thus the 3
> >     functions
> >
> >     - `org-dp-create'
> >
> >     - `org-dp-rewire'
> >
> >     - `org-dp-prompt'
> >
> >     should be all you need for all kinds of programming
> >     tasks. `org-dp-wrap-in-block' is one example of how to program
> >     with
> >     org-dp, `org-dp-toggle-headers' is another one.
> >
> >     Hope that this is useful.
> >
> >     PS
> >
> >     For the sake of completeness, here the docstring of
> >     `org-dp-wrap-in-block':
> >
> >     ,----[ C-h f org-dp-wrap-in-block RET ]
> >     | org-dp-wrap-in-block is an interactive Lisp function in
> >     | `org-dp-lib.el'.
> >     |
> >     | It is bound to C-c w w.
> >     |
> >     | (org-dp-wrap-in-block &optional LINES USER-INFO)
> >     |
> >     | 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
> >     | forward/backward 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.
> >     `----
> >
> >     --
> >     cheers,
> >     Thorsten
> >
> >
> >
> >
>
> --
> cheers,
> Thorsten
>
>
>

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

  reply	other threads:[~2015-03-07  6:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-19 14:14 [ANN] org-dp-wrap-in-block Thorsten Jolitz
2014-08-19 17:15 ` Xebar Saram
2014-08-19 19:41   ` Thorsten Jolitz
2015-03-07  6:37     ` Xebar Saram [this message]
2015-03-07  8:08       ` Xebar Saram

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='CAOQHXPrZhEmbwXYJ4mn_PvjiOnX-=NKEkeX4EHwHGzWJd_XJ_w@mail.gmail.com' \
    --to=zeltakc@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=tjolitz@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).