emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* how to highlight the background of my current paragraph?
@ 2019-10-31  7:35 Sharon Kimble
  2019-10-31  7:52 ` Diego Zamboni
  0 siblings, 1 reply; 8+ messages in thread
From: Sharon Kimble @ 2019-10-31  7:35 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 452 bytes --]


How can I set the background of my current paragraph to 'dark gray',
i.e. to highlight it, and the highlighting to follow whichever paragraph
I'm currently viewing/writing please?

I've been googling it but haven't found anything suitable so far.

Thanks
Sharon.
-- 
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: how to highlight the background of my current paragraph?
  2019-10-31  7:35 how to highlight the background of my current paragraph? Sharon Kimble
@ 2019-10-31  7:52 ` Diego Zamboni
  2019-10-31 15:56   ` Fraga, Eric
  0 siblings, 1 reply; 8+ messages in thread
From: Diego Zamboni @ 2019-10-31  7:52 UTC (permalink / raw)
  To: Sharon Kimble; +Cc: Org-mode

[-- Attachment #1: Type: text/plain, Size: 954 bytes --]

I use =global-hl-line-mode= from the hl-line package. Highlights only the
current line, but I find it quite useful. Here's what I have in my config:

(use-package hl-line
    :defer nil
    :config
    (global-hl-line-mode))

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).

Hope this helps,
--Diego


On Thu, Oct 31, 2019 at 8:36 AM Sharon Kimble <boudiccas@skimble.plus.com>
wrote:

>
> How can I set the background of my current paragraph to 'dark gray',
> i.e. to highlight it, and the highlighting to follow whichever paragraph
> I'm currently viewing/writing please?
>
> I've been googling it but haven't found anything suitable so far.
>
> Thanks
> Sharon.
> --
> 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 #2: Type: text/html, Size: 1644 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: how to highlight the background of my current paragraph?
  2019-10-31  7:52 ` Diego Zamboni
@ 2019-10-31 15:56   ` Fraga, Eric
  2019-10-31 16:03     ` Diego Zamboni
  0 siblings, 1 reply; 8+ messages in thread
From: Fraga, Eric @ 2019-10-31 15:56 UTC (permalink / raw)
  To: Diego Zamboni; +Cc: Org-mode, Sharon Kimble

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: how to highlight the background of my current paragraph?
  2019-10-31 15:56   ` Fraga, Eric
@ 2019-10-31 16:03     ` Diego Zamboni
  2019-10-31 16:10       ` Diego Zamboni
  0 siblings, 1 reply; 8+ messages in thread
From: Diego Zamboni @ 2019-10-31 16:03 UTC (permalink / raw)
  To: Fraga, Eric; +Cc: Org-mode, Sharon Kimble

[-- Attachment #1: Type: text/plain, Size: 1034 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 1508 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: how to highlight the background of my current paragraph?
  2019-10-31 16:03     ` Diego Zamboni
@ 2019-10-31 16:10       ` Diego Zamboni
  2019-10-31 16:22         ` Fraga, Eric
  2019-11-01 11:44         ` Sharon Kimble
  0 siblings, 2 replies; 8+ messages in thread
From: Diego Zamboni @ 2019-10-31 16:10 UTC (permalink / raw)
  To: Fraga, Eric; +Cc: Org-mode, Sharon Kimble

[-- Attachment #1: Type: text/plain, Size: 1688 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2573 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: how to highlight the background of my current paragraph?
  2019-10-31 16:10       ` Diego Zamboni
@ 2019-10-31 16:22         ` Fraga, Eric
  2019-10-31 16:43           ` Fraga, Eric
  2019-11-01 11:44         ` Sharon Kimble
  1 sibling, 1 reply; 8+ messages in thread
From: Fraga, Eric @ 2019-10-31 16:22 UTC (permalink / raw)
  To: Diego Zamboni; +Cc: Org-mode

On Thursday, 31 Oct 2019 at 17:10, Diego Zamboni wrote:
> 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:

Thanks for this.

Interesting effect.  I had to add ":extend t" to the hl-line face (which
I customized a long time ago now) to get the extension to the end of the
window.  However, although the background colour now goes to the end,
other effects do not (underline and overline).  Something for the Emacs
development mailing list where I know there has been quite a bit of
discussion on the :extend feature.

Thanks again,
eric

PS - I've removed Sharon from the CC list given our hijacking of the thread! :-)

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: how to highlight the background of my current paragraph?
  2019-10-31 16:22         ` Fraga, Eric
@ 2019-10-31 16:43           ` Fraga, Eric
  0 siblings, 0 replies; 8+ messages in thread
From: Fraga, Eric @ 2019-10-31 16:43 UTC (permalink / raw)
  To: Diego Zamboni; +Cc: Org-mode

So, I updated Emacs to latest git version and the extended face works
for all attributes.  However, it brings in other edge effects:

1. the extension backwards wraps to the previous line in some cases and
2. my cursor disappears if it is past the last character on the line
   when using a block cursor in evil mode.

So I'm back to what I had before until Emacs stabilises a bit in terms
of face extensions.

And enough off-topic discussion, I think!  Apologies to all for the
noise.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: how to highlight the background of my current paragraph?
  2019-10-31 16:10       ` Diego Zamboni
  2019-10-31 16:22         ` Fraga, Eric
@ 2019-11-01 11:44         ` Sharon Kimble
  1 sibling, 0 replies; 8+ messages in thread
From: Sharon Kimble @ 2019-11-01 11:44 UTC (permalink / raw)
  To: Diego Zamboni; +Cc: Org-mode, Fraga, Eric

[-- Attachment #1: Type: text/plain, Size: 2844 bytes --]

Diego Zamboni <diego@zzamboni.org> 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 <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 =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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-11-01 11:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-31  7:35 how to highlight the background of my current paragraph? Sharon Kimble
2019-10-31  7:52 ` Diego Zamboni
2019-10-31 15:56   ` Fraga, Eric
2019-10-31 16:03     ` Diego Zamboni
2019-10-31 16:10       ` Diego Zamboni
2019-10-31 16:22         ` Fraga, Eric
2019-10-31 16:43           ` Fraga, Eric
2019-11-01 11:44         ` Sharon Kimble

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).