emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Alexander Vorobiev <alexander.vorobiev@gmail.com>
To: Thorsten Jolitz <tjolitz@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Org-mode outside Org-mode
Date: Wed, 24 Apr 2013 09:20:17 -0500	[thread overview]
Message-ID: <CAGOCFPU1YJ-Nvk=Qdq9P93Zf=3gZP0GG1GA+=+1jnChk3_-bFA@mail.gmail.com> (raw)
In-Reply-To: <87txoc7jvr.fsf@gmail.com>

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

First of all, thank you for the tutorial and the code! Outshine has become
a major component of my workflow, I use it in all my source code buffers
(sql, R, elisp).

I have one question/proposal regarding key bindings. Outshine binds TAB
to outshine-cycle-subtree which only does something useful (calls
outshine-cycle)
when the point is on a header line, otherwise it prints a message. TAB is
used
 heavily in various source code -related modes (yasnippets, smart-tab, etc.
http://www.emacswiki.org/emacs/TabCompletion is a great source for those) -
the
behavior which I don't want to lose. There is some support of other TAB
behaviors in
outline-cycle but it is not used (and it ignores the user-defined bindings).

A while back I wrote a macro (based on the advice in
http://stackoverflow.com/a/2494384/973603) which allows to activate minor
mode
bindings when a condition is true and fall back to previous bindings
otherwise:

(defmacro define-key-with-fallback (keymap key def condition &optional
mode)
 "Define key with fallback. Binds KEY to definition DEF in keymap KEYMAP,
the
  binding is active when the CONDITION is true. Otherwise turns MODE off
and
  re-enables previous definition for KEY. If MODE is nil, tries to recover
it by
  stripping off \"-map\" from KEYMAP name."
  `(define-key ,keymap ,key (lambda () (interactive)
     (if ,condition ,def
       (let* ((,(if mode mode
                     (let* ((keymap-str (symbol-name keymap))
                               (mode-name-end (- (string-width keymap-str)
4)))
                        (if (string= "-map" (substring keymap-str
mode-name-end))
                          (intern (substring keymap-str 0 mode-name-end))
                          (error "Could not deduce mode name from keymap
name (\"-map\" missing?)")))) nil)
                 (original-func (key-binding ,key)))
           (call-interactively original-func))))))

So now I can just do

(define-key-with-fallback outline-minor-mode-map (kbd "TAB") (outline-cycle
1) (outline-on-heading-p))

and have my yasnippets and smart indentation/completion active again. My
question is am I reinventing
the wheel? Is there a function/macro in org-mode or elsewhere that would
allow me define key bindings
with fallback?

Thanks again,
Alex


On Fri, Mar 15, 2013 at 10:39 AM, Thorsten Jolitz <tjolitz@gmail.com> wrote:

>
> Hi List,
>
> there is a now a tutorial on Worg describing the recently announced new
> libraries for using (concepts and functionality of) Org-mode when
> outside Org-mode:
>
> ,-----------------------------------------------------------
> | http://orgmode.org/worg/org-tutorials/org-outside-org.html
> `-----------------------------------------------------------
>
> Besides using the 'well-known' orgstruct-minor-mode, you can now:
>
> - use outline-minor-mode with *outshine.el* extensions and structure
>   your file with outshine-style headlines, giving your source-code files
>   the look&feel of Org-mode files. Should work in any major-mode.
>
> - use *outorg.el* to edit complete subtrees or the whole file as
>   Org-mode in a temporary Org-mode edit-buffer. Depends on outshine.
>
> - use *navi-mode.el* to open an occur-like indirect buffer for
>   super-fast navigation and structure-editing (as well as other common
>   actions on subtrees) in the associated original-buffer - all with
>   one-key commands in a read-only buffer. A kind of customizable
>   remote-control for the original-buffer with many views combining
>   headline and keyword searches and easy switching between the
>   associated buffers. Depends somehow on outshine too, but to a much
>   lesser degree than outorg.el
>
> And of course you have Francois Pinard's *poporg.el* and can (completely
> independent from orgstruct or outshine):
>
> - edit atomic comment-sections (anywhere in a source-code buffer, no
>   matter what major-mode) in a temporary Org-mode edit-buffer. Thus,
>   while *outorg* gives you a whole subtree with headline and source-code
>   blocks in a temporary Org-mode edit-buffer, *poporg* gives you only
>   the comment-string near point and nothing else, so that both libraries
>   complement each other really well in their usage.
>
> For more details see the tutorial on Worg.
>
> --
> cheers,
> Thorsten
>
>
>
>

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

  parent reply	other threads:[~2013-04-24 14:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-15 15:39 Org-mode outside Org-mode Thorsten Jolitz
2013-03-15 16:47 ` Thomas S. Dye
2013-04-03 18:23 ` Samuel Wales
2013-04-04 14:09   ` Thorsten Jolitz
2013-04-04 20:17     ` Samuel Wales
2013-04-05  9:51       ` Thorsten Jolitz
2013-04-07  1:05         ` Eric Schulte
2013-04-07  7:49           ` Bastien
2013-04-12  1:04           ` Samuel Wales
2013-04-13 20:48           ` Samuel Wales
2013-04-12  1:19         ` Samuel Wales
2013-04-12 10:44           ` Thorsten Jolitz
2013-04-13 20:45             ` Samuel Wales
2013-04-27  8:35               ` Thorsten Jolitz
2013-04-24 14:20 ` Alexander Vorobiev [this message]
2013-04-24 18:39   ` Thorsten Jolitz
2013-04-25 17:33   ` Thorsten Jolitz

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='CAGOCFPU1YJ-Nvk=Qdq9P93Zf=3gZP0GG1GA+=+1jnChk3_-bFA@mail.gmail.com' \
    --to=alexander.vorobiev@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).