emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to highlight the background of my current paragraph?


From: Sharon Kimble
Subject: Re: how to highlight the background of my current paragraph?
Date: Fri, 01 Nov 2019 11:44:45 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Diego Zamboni <address@hidden> writes:

> (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

Thanks Eric and Diego.

I've used Diego's script from above with a slight adjustment to achieve
my need for the highlighted line to show as 'gray' in the
face-background line.

#+begin_src emacs-lisp
  (defun esf/get-visual-line-range ()
(set-face-background 'hl-line "gray30")
    (let (b e)
      (save-excursion
        (beginning-of-visual-line)
        (setq b (point))
        (end-of-visual-line)
        (setq e (+ 1 (point)))
        )
      (cons b e)))
  (setq hl-line-range-function #'esf/get-visual-line-range)
#+end_src

Thanks both.
Sharon.

>
> --Diego
>
> On Thu, Oct 31, 2019 at 5:03 PM Diego Zamboni <address@hidden> wrote:
>
>     Hi Eric,
>    
>     Nice! Thanks for the tip :)
>    
>     --Diego
>
>     On Thu, Oct 31, 2019 at 4:56 PM Fraga, Eric <address@hidden> 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

-- 
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
DrugFacts = https://www.drugfacts.org.uk
Debian 10.1, fluxbox 1.3.7, emacs 26.3, org 9.2.6

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]