From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: function for inserting a block Date: Mon, 16 Oct 2017 12:46:42 -0700 Message-ID: <87tvyyvpst.fsf@ericabrahamsen.net> References: <877exghblx.fsf@ericabrahamsen.net> <87efromccg.fsf@nicolasgoaziou.fr> <87ziabepxt.fsf@ericabrahamsen.net> <87bmml2fb0.fsf@ericabrahamsen.net> <87fubuzpsa.fsf@nicolasgoaziou.fr> <874lsabdop.fsf@ericabrahamsen.net> <87vak1l11m.fsf@nicolasgoaziou.fr> <87r2uoc4q7.fsf@ericabrahamsen.net> <87bmllk5xy.fsf@nicolasgoaziou.fr> <878tgmwwsa.fsf@ericabrahamsen.net> <87po9q2e8k.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38653) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4BNN-0003U4-4p for emacs-orgmode@gnu.org; Mon, 16 Oct 2017 15:48:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4BNJ-0000Ts-P4 for emacs-orgmode@gnu.org; Mon, 16 Oct 2017 15:48:37 -0400 Received: from [195.159.176.226] (port=37020 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e4BNJ-0000Sb-Hj for emacs-orgmode@gnu.org; Mon, 16 Oct 2017 15:48:33 -0400 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1e4BMz-0007zP-Hv for emacs-orgmode@gnu.org; Mon, 16 Oct 2017 21:48:13 +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" To: emacs-orgmode@gnu.org Nicolas Goaziou writes: > Hello, > > Eric Abrahamsen writes: > >> How does this look? > > Thank you! I have some questions and remarks. > >> * etc/ORG-NEWS: Mention in news. > > This doesn't need to be added to the commit message. > >> +Do not be put off by having to remember the source block syntax. Org mode >> +offers two ways of speeding up the creation of @samp{src} code blocks: > > src code blocks > > is enough, IMO. There are may of them across the manual, and it just > makes reading more tedious. > >> +@findex org-insert-structure-template > > I would also add > > @kindex C-c C-x t > >> + (let ((s (copy-marker (if (use-region-p) >> + (region-beginning) >> + (point)))) > > Does it really need to be a marker? AFAICT, nothing really changes this > position. > >> + (back-to-indentation) n>> + (insert (format "#+BEGIN_%s\n" >> + type)) >> + (indent-to column) > > What about > > (beginning-of-line) > (indent-to column) > (insert (format "#+BEGIN_%s\n" type)) > > ? > > It avoids `back-to-indentation'. Cool, I will make all of the above changes, thanks for the notes. >> + (if (bolp) >> + (progn >> + (skip-chars-backward " \n\t") >> + (forward-char)) >> + (end-of-line) >> + (insert "\n")) > > I don't understand this part. In particular, the `forward-char' looks > wrong. Do you mean `forward-line' ? If so, do you handle the case where > buffer doesn't end with a newline character? This was a bit of finicky code mostly for aesthetic purposes. It has to do with this case (the second clause in the test I added): #+BEGIN_SRC org This is a paragraph This is another paragraph #+END_SRC If point is on the first paragraph and the region is not active, `org-mark-element' will mark the paragraph and all following whitespace, which means we end up with: #+BEGIN_SRC org #+BEGIN_FOO This is a paragraph. #+END_FOO This is another paragraph. #+END_SRC Which just looked bad to me (even though it probably behaves perfectly correctly). So if point is at bol, it skips back over the whitespace and then moves forward one char, presumably leaving point right after the marked element. Maybe it should only skip back over newlines (though then indentation will confuse it). Or maybe I should just not be so picky about appearances... Eric