From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz Subject: Re: Org-mode outside Org-mode Date: Wed, 24 Apr 2013 20:39:20 +0200 Message-ID: <87vc7b22p3.fsf@gmail.com> References: <87txoc7jvr.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:58335) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UV4bO-0005LD-2C for emacs-orgmode@gnu.org; Wed, 24 Apr 2013 14:39:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UV4bM-0007Fy-8R for emacs-orgmode@gnu.org; Wed, 24 Apr 2013 14:39:34 -0400 Received: from plane.gmane.org ([80.91.229.3]:57965) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UV4bL-0007Fh-VJ for emacs-orgmode@gnu.org; Wed, 24 Apr 2013 14:39:32 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UV4bJ-00042x-Ni for emacs-orgmode@gnu.org; Wed, 24 Apr 2013 20:39:29 +0200 Received: from g231105207.adsl.alicedsl.de ([92.231.105.207]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 24 Apr 2013 20:39:29 +0200 Received: from tjolitz by g231105207.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 24 Apr 2013 20:39:29 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Alexander Vorobiev writes: Hi Alexander, > 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). Thanks, I use it in all my elisp and PicoLisp buffers too, and I'm happy that it works for you too. Only with 'old-school' elisp buffers with '^;;;+ ' headlines there is still one major headache with long lines of only ';' like this: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; that make the regexp matcher enter endless backtracking. I haven't found a solution yet how to fontify the headlines in a different way (-> first match the headline regexp, then calculate the headline level). > 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). That very same problem made me hate yasnippet ... I think thats a very good proposal. > 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: I copied your macro to outshine.el (hope thats ok with you, I credit you), but had errors at start-up so I modified it slightly: ,----------------------------------------------------------------------------------- | ;; copied from Alexander Vorobiev | ;; http://www.mail-archive.com/emacs-orgmode@gnu.org/msg70648.html | (defmacro outshine-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)) | (message "Could not deduce mode name from keymap name")) | ;; (\\"-map\\" missing?)") | )) nil) | (original-func (key-binding ,key))) | (call-interactively original-func)))))) `----------------------------------------------------------------------------------- This is what I get now if I press 'C-h k' and then TAB in an outshine buffer: ,--------------------------------------------------------------------------- | TAB (translated from ) runs the command (lambda nil (interactive) (if | (outline-on-heading-p) (outline-cycle 1) (let* ((outline-minor-mode nil) | (original-func (key-binding (kbd "TAB")))) (call-interactively | original-func)))), which is an interactive Lisp function. | | It is bound to TAB. | | (anonymous) `--------------------------------------------------------------------------- This is still in a private branch and not merged with the master, it seems to work, but could you check the macro and the message if they look alright before merging it with master? > So now I can just do > > (define-key-with-fallback outline-minor-mode-map (kbd "TAB") (outline-cycle 1) > (outline-on-heading-p))  I applied that to several bindings in outshine.el that might conflict with other libraries now. > 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? I would be interested in this too, since I like to have the M- navigation keys from 'outline-mode-easy-bindings' in Org-mode too, but they conflict with some org-table bindings. -- cheers, Thorsten