From: "Thomas S. Dye" <tsd@tsdye.com>
To: Dan Davison <davison@stats.ox.ac.uk>
Cc: emacs-orgmode Mailinglist <emacs-orgmode@gnu.org>
Subject: Re: Context sensitive M-q
Date: Tue, 7 Sep 2010 10:28:47 -1000 [thread overview]
Message-ID: <E5302D11-89FF-4B88-9B71-AD3CD9E93C98@tsdye.com> (raw)
In-Reply-To: <87fwxlweqx.fsf@stats.ox.ac.uk>
Thanks Dan,
Quick hack 2 does exactly what I want for the simple and (for me)
frequent use case of issuing M-q in a source block while in Org-mode.
I think it might be useful to have this functionality in Org-mode, if
it could be implemented without too much difficulty.
All the best,
Tom
On Sep 7, 2010, at 9:11 AM, Dan Davison wrote:
> "Thomas S. Dye" <tsd@tsdye.com> writes:
>
>> Aloha all,
>>
>> I can't break myself of the M-q habit and often call fill-paragraph
>> inside a source code block while the buffer is in Org-mode.
>> Typically, this rearranges the source code in an undesirable way. Is
>> there some way (other than breaking the M-q habit) that I can protect
>> source code blocks from Org-mode's fill-paragraph?
>
> Hi Tom,
>
> Two quick hacks[1] below. It seems that some major modes (e.g. C) use
> M-q for something sensible, whereas others (e.g. R) don't. I'm also an
> M-q addict, but I guess I don't use it much in language major modes,
> so
> I'll try using (1). With (2), you have to be happy with the
> (invisible)
> excursion to the edit buffer and back, and any consequent changes to
> your indentation, etc.
>
> 1. Do nothing on M-q in code block
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> (defun dan/org-fill-paragraph-no-op-maybe ()
> (interactive)
> (if (org-babel-where-is-src-block-head)
> (message "In code block: doing nothing")
> (call-interactively 'fill-paragraph)))
>
> (define-key org-mode-map "\M-q" 'dan/org-fill-paragraph-no-op-maybe)
>
> 2. Call native M-q
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> (defun dan/org-fill-paragraph-natively-maybe ()
> (interactive)
> (or (org-babel-do-key-sequence-in-edit-buffer "\M-q")
> (call-interactively 'fill-paragraph)))
>
> (define-key org-mode-map "\M-q" 'dan/org-fill-paragraph-natively-
> maybe)
>
>
> Dan
>
> Footnotes:
>
> [1] E.g. `org-babel-where-is-src-block-head' may not be the "proper"
> way
> to detect if we're in a src block.
>
>
>
>>
>> All the best,
>> Tom
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Please use `Reply All' to send replies to the list.
>> Emacs-orgmode@gnu.org
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
prev parent reply other threads:[~2010-09-07 20:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-07 18:34 Context sensitive M-q Thomas S. Dye
2010-09-07 19:11 ` Dan Davison
2010-09-07 19:30 ` org-babel-where-is-src-block-head Jambunathan K
2010-09-07 20:40 ` org-babel-where-is-src-block-head Nicolas Goaziou
2010-09-07 20:46 ` org-babel-where-is-src-block-head Dan Davison
2010-09-07 20:28 ` Thomas S. Dye [this message]
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=E5302D11-89FF-4B88-9B71-AD3CD9E93C98@tsdye.com \
--to=tsd@tsdye.com \
--cc=davison@stats.ox.ac.uk \
--cc=emacs-orgmode@gnu.org \
/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).