From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Thomas S. Dye" Subject: Re: Context sensitive M-q Date: Tue, 7 Sep 2010 10:28:47 -1000 Message-ID: References: <38B5DC68-38DC-4F36-8D26-F050D4F42036@tsdye.com> <87fwxlweqx.fsf@stats.ox.ac.uk> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from [140.186.70.92] (port=56201 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ot4ml-0007qQ-5J for emacs-orgmode@gnu.org; Tue, 07 Sep 2010 16:28:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ot4mj-0001Tq-P3 for emacs-orgmode@gnu.org; Tue, 07 Sep 2010 16:28:54 -0400 Received: from oproxy2-pub.bluehost.com ([67.222.39.60]:52087) by eggs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1Ot4mj-0001Tg-Fe for emacs-orgmode@gnu.org; Tue, 07 Sep 2010 16:28:53 -0400 In-Reply-To: <87fwxlweqx.fsf@stats.ox.ac.uk> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Dan Davison Cc: emacs-orgmode Mailinglist 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" 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 >