From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Re: function for inserting a block Date: Mon, 23 Oct 2017 14:46:41 +0000 Message-ID: References: <877exghblx.fsf@ericabrahamsen.net> <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> <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> <871slx4j6p.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="94eb2c07de52b18e61055c37e452" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6e0I-0004le-7w for emacs-orgmode@gnu.org; Mon, 23 Oct 2017 10:47:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6e0E-0004VN-Ac for emacs-orgmode@gnu.org; Mon, 23 Oct 2017 10:46:58 -0400 Received: from mail-yw0-x231.google.com ([2607:f8b0:4002:c05::231]:45288) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e6e0E-0004VC-4w for emacs-orgmode@gnu.org; Mon, 23 Oct 2017 10:46:54 -0400 Received: by mail-yw0-x231.google.com with SMTP id j4so12250413ywb.2 for ; Mon, 23 Oct 2017 07:46:53 -0700 (PDT) In-Reply-To: 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: Carsten Dominik Cc: Eric Abrahamsen , emacs-org list , Nicolas Goaziou --94eb2c07de52b18e61055c37e452 Content-Type: text/plain; charset="UTF-8" On Mon, Oct 23, 2017 at 10:00 AM Carsten Dominik wrote: > I am not sure I understand, at least with transient-region turned on. > Typing You're correct. > Or do you mean to actually put "<" into a keymap? > I actually do that in my personal config .. Maybe binding "<" in org keymap is the simplest way. I have this function in my config bound to "<": (defun modi/org-template-maybe () "Insert org-template if point is at the beginning of the line, or if a region is selected. Else call `self-insert-command'." (interactive) (let ((is-region? (use-region-p))) (if (or is-region? (and (not is-region?) (looking-back "^[[:blank:]]*"))) (hydra-org-template/body) ;Wrapper function for `org-try-structure-completion' (self-insert-command 1)))) -- Kaushal Modi --94eb2c07de52b18e61055c37e452 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Oct 23= , 2017 at 10:00 AM Carsten Dominik <do= minik@uva.nl> wrote:
I am not su= re I understand, at least with transient-region turned on.=C2=A0 Typing <= ;e will deactivate the region, so there is no effect.
=

You're correct.=C2=A0
=C2=A0=
Or do you mean to actua= lly put "<" into a keymap?

I actually do that in my personal config .. Maybe bind= ing "<" in org keymap is the simplest way.

I have this function in my config bound to "<":

(defun modi/org-template-maybe ()
=C2=A0 &q= uot;Insert org-template if point is at the beginning of the line,
or if a region is selected.=C2=A0 Else call `self-insert-command'.&quo= t;
=C2=A0 (interactive)
=C2=A0 (let ((is-region? (use-r= egion-p)))
=C2=A0 =C2=A0 (if (or is-region?
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (and (not is-region?)
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(looking-back "^[[= :blank:]]*")))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (hydra-org-templa= te/body) ;Wrapper function for `org-try-structure-completion'
=C2=A0 =C2=A0 =C2=A0 (self-insert-command 1))))
--

Kaushal Modi

--94eb2c07de52b18e61055c37e452--