From: Sharon Kimble <boudiccas@skimble.plus.com>
To: Diego Zamboni <diego@zzamboni.org>
Cc: Org-mode <emacs-orgmode@gnu.org>, "Fraga, Eric" <e.fraga@ucl.ac.uk>
Subject: Re: how to highlight the background of my current paragraph?
Date: Fri, 01 Nov 2019 11:44:45 +0000 [thread overview]
Message-ID: <87eeyrhlci.fsf@skimble.plus.com> (raw)
In-Reply-To: <CAGY83EfDsf=3vHKJ9H7o343Wf4_GFSLL6Jgjh-VQPSb8k4RNrA@mail.gmail.com> (Diego Zamboni's message of "Thu, 31 Oct 2019 17:10:53 +0100")
[-- 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 --]
prev parent reply other threads:[~2019-11-01 11:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87eeyrhlci.fsf@skimble.plus.com \
--to=boudiccas@skimble.plus.com \
--cc=diego@zzamboni.org \
--cc=e.fraga@ucl.ac.uk \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public 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).