From mboxrd@z Thu Jan 1 00:00:00 1970 From: Diego Zamboni Subject: Re: how to highlight the background of my current paragraph? Date: Thu, 31 Oct 2019 17:10:53 +0100 Message-ID: References: <87lft1tljb.fsf@skimble.plus.com> <8736f8sycr.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000a04eac05963718f9" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:35917) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iQD2R-0005Nf-9F for emacs-orgmode@gnu.org; Thu, 31 Oct 2019 12:11:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iQD2P-0005t5-QG for emacs-orgmode@gnu.org; Thu, 31 Oct 2019 12:11:06 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:33018) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iQD2P-0005qh-Bj for emacs-orgmode@gnu.org; Thu, 31 Oct 2019 12:11:05 -0400 Received: by mail-wr1-x431.google.com with SMTP id s1so6913897wro.0 for ; Thu, 31 Oct 2019 09:11:05 -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: "Fraga, Eric" Cc: Org-mode , Sharon Kimble --000000000000a04eac05963718f9 Content-Type: text/plain; charset="UTF-8" (sorry, further hijacking this thread) Eric: I made a slight improvement to your code (see the =setq e=) so that the empty space at the end of the line gets highlighted as in the default behavior instead of only highlighting the part of the line that contains text: #+begin_src emacs-lisp (defun esf/get-visual-line-range () (let (b e) (save-excursion (beginning-of-visual-line) (setq b (point)) (end-of-visual-line) (setq e (+ 1 (point))) ) (cons b e))) #+end_src --Diego On Thu, Oct 31, 2019 at 5:03 PM Diego Zamboni wrote: > Hi Eric, > > Nice! Thanks for the tip :) > > --Diego > > > On Thu, Oct 31, 2019 at 4:56 PM Fraga, Eric wrote: > >> On Thursday, 31 Oct 2019 at 08:52, Diego Zamboni wrote: >> > Since I use =visual-line-mode= as well in my org documents, the effect >> is >> > to highlight the whole current paragraph (which is a single line in the >> > file). >> >> In case you find this useful, I found that highlighting the whole >> paragraph was too much; I want just the actual "physical" line where >> point is highlighted, whether it continues on or not. I do this: >> >> #+begin_src emacs-lisp >> (defun esf/get-visual-line-range () >> (let (b e) >> (save-excursion >> (beginning-of-visual-line) >> (setq b (point)) >> (end-of-visual-line) >> (setq e (point)) >> ) >> (cons b e))) >> (setq hl-line-range-function #'esf/get-visual-line-range) >> #+end_src >> >> Of course, this is not what the OP wanted so excuse the diversion. >> >> -- >> Eric S Fraga via Emacs 27.0.50, Org release_9.2.6-552-g8c5a78 >> > --000000000000a04eac05963718f9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
(sorry, further hijacking this thread)

= Eric: I made a slight improvement to your code (see the =3Dsetq e=3D) so th= at the empty space at the end of the line gets highlighted as in the defaul= t behavior instead of only highlighting the part of the line that contains = text:

#+begin_src emacs-lisp
(defun esf/= get-visual-line-range ()
=C2=A0 =C2=A0 (let (b e)
=C2=A0 =C2=A0 =C2= =A0 (save-excursion
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (beginning-of-visual-lin= e)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq b (point))
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 (end-of-visual-line)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq e (+ 1 (po= int)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 )
=C2=A0 =C2=A0 =C2=A0 (cons b e))= )
#+end_src

--Diego


On Thu, Oct 31, 2019 at 5:03 PM Diego Zamboni <diego@zzamboni.org> wrote:
Hi Eric,

=
Nice! Thanks for the tip :)

--Diego


On Thu, Oct 31, 2019 at 4:56 PM Fraga, Eric <e.fraga@ucl.ac.uk> wrote:
=
On Thursday, 31 Oct= 2019 at 08:52, Diego Zamboni wrote:
> Since I use =3Dvisual-line-mode=3D as well in my org documents, the ef= fect is
> to highlight the whole current paragraph (which is a single line in th= e
> file).

In case you find this useful, I found that highlighting the whole
paragraph was too much; I want just the actual "physical" line wh= ere
point is highlighted, whether it continues on or not.=C2=A0 I do this:

#+begin_src emacs-lisp
=C2=A0 (defun esf/get-visual-line-range ()
=C2=A0 =C2=A0 (let (b e)
=C2=A0 =C2=A0 =C2=A0 (save-excursion
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (beginning-of-visual-line)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq b (point))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (end-of-visual-line)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq e (point))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 )
=C2=A0 =C2=A0 =C2=A0 (cons b e)))
=C2=A0 (setq hl-line-range-function #'esf/get-visual-line-range)
#+end_src

Of course, this is not what the OP wanted so excuse the diversion.

--
Eric S Fraga via Emacs 27.0.50, Org release_9.2.6-552-g8c5a78
--000000000000a04eac05963718f9--