From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: function for inserting a block Date: Fri, 20 Oct 2017 14:15:14 -0700 Message-ID: <87wp3p34il.fsf@ericabrahamsen.net> References: <877exghblx.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> <87tvyyvpst.fsf@ericabrahamsen.net> <87fuaiz069.fsf@nicolasgoaziou.fr> <87lgk9eo4d.fsf@ericabrahamsen.net> <87fuahxxvs.fsf@nicolasgoaziou.fr> <87r2u1cuwj.fsf@ericabrahamsen.net> <87infdctzq.fsf@ericabrahamsen.net> <87k1zsbizs.fsf@ericabrahamsen.net> <87k1zp4rxj.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57283) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5eiN-0005EY-Ee for emacs-orgmode@gnu.org; Fri, 20 Oct 2017 17:20:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5eiK-0008RU-9d for emacs-orgmode@gnu.org; Fri, 20 Oct 2017 17:20:23 -0400 Received: from [195.159.176.226] (port=37357 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5eiK-0008Qw-2P for emacs-orgmode@gnu.org; Fri, 20 Oct 2017 17:20:20 -0400 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1e5ei5-0007Xu-6U for emacs-orgmode@gnu.org; Fri, 20 Oct 2017 23:20:05 +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 Kaushal Modi writes: > Also, if the type is "src", shouldn't the point end up after "#+BEGIN_SRC"? Because the user will anyways need to type something there. My original version did that. It might be nice to still do that selectively if the user adds a SRC or EXPORT block. > Finally, I am trying to understand what this does: > > (if (bolp) > (progn > (skip-chars-backward " \n\t") > (forward-line)) > ;; snip > ) > > If the point is at BOL, wouldn't that progn bring the point exactly to where it was, as the same BOL? Also isn't that progn equivalent to (forward-line 0)? > > I am probably missing something.. but seems to work the same with > > (unless (bolp) > (end-of-line) > (insert "\n")) > > replacing that whole (if ..) form. The case this is addressing is if there are multiple newlines after the org element we're wrapping (one of the clauses in the test shows this). The skip-chars-backward is there to go back over multiple newlines, so that the #+END_FOO string always comes right after the end of the text. Eric