all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Display line number on each buffer line
@ 2021-12-02  8:18 fatiparty--- via Users list for the GNU Emacs text editor
  2021-12-02  8:31 ` Lars Ingebrigtsen
       [not found] ` <87mtljmmqh.fsf@gnus.org-MpuGQO3----2>
  0 siblings, 2 replies; 14+ messages in thread
From: fatiparty--- via Users list for the GNU Emacs text editor @ 2021-12-02  8:18 UTC (permalink / raw)
  To: Help Gnu Emacs

Is there a way to display the line number on each buffer line?


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

* Re: Display line number on each buffer line
  2021-12-02  8:18 Display line number on each buffer line fatiparty--- via Users list for the GNU Emacs text editor
@ 2021-12-02  8:31 ` Lars Ingebrigtsen
       [not found] ` <87mtljmmqh.fsf@gnus.org-MpuGQO3----2>
  1 sibling, 0 replies; 14+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-02  8:31 UTC (permalink / raw)
  To: fatiparty--- via Users list for the GNU Emacs text editor; +Cc: fatiparty

fatiparty--- via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> Is there a way to display the line number on each buffer line?

`M-x display-line-numbers-mode'

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



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

* Display line number on each buffer line
       [not found] ` <87mtljmmqh.fsf@gnus.org-MpuGQO3----2>
@ 2021-12-02  9:02   ` fatiparty--- via Users list for the GNU Emacs text editor
  2021-12-02  9:17     ` Philip Kaludercic
                       ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: fatiparty--- via Users list for the GNU Emacs text editor @ 2021-12-02  9:02 UTC (permalink / raw)
  To: Lars Ingebrigtsen
  Cc: fatiparty--- via Users list for the GNU Emacs text editor

Dec 2, 2021, 08:31 by larsi@gnus.org:

> fatiparty--- via Users list for the GNU Emacs text editor
> <help-gnu-emacs@gnu.org> writes:
>
>> Is there a way to display the line number on each buffer line?
>>
>
> `M-x display-line-numbers-mode'
>
That's what I was looking for.  Is there a technique for changing the foreground colour of the line number as well?



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

* Re: Display line number on each buffer line
  2021-12-02  9:02   ` fatiparty--- via Users list for the GNU Emacs text editor
@ 2021-12-02  9:17     ` Philip Kaludercic
       [not found]     ` <875ys7z7pl.fsf@posteo.net-MpuQz9y----2>
  2021-12-03 20:53     ` Jean Louis
  2 siblings, 0 replies; 14+ messages in thread
From: Philip Kaludercic @ 2021-12-02  9:17 UTC (permalink / raw)
  To: fatiparty--- via Users list for the GNU Emacs text editor
  Cc: fatiparty, Lars Ingebrigtsen

fatiparty--- via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> Dec 2, 2021, 08:31 by larsi@gnus.org:
>
>> fatiparty--- via Users list for the GNU Emacs text editor
>> <help-gnu-emacs@gnu.org> writes:
>>
>>> Is there a way to display the line number on each buffer line?
>>>
>>
>> `M-x display-line-numbers-mode'
>>
> That's what I was looking for.  Is there a technique for changing the foreground colour of the line number as well?

You can customise the faces line-number (for all lines) and
line-number-current-line (for the current line).  Use `M-x
customize-face [face name]' to do this interactively.

-- 
	Philip Kaludercic



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

* Display line number on each buffer line
       [not found]     ` <875ys7z7pl.fsf@posteo.net-MpuQz9y----2>
@ 2021-12-02 12:06       ` fatiparty--- via Users list for the GNU Emacs text editor
  2021-12-02 13:33         ` Alejandro Barocio A.
                           ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: fatiparty--- via Users list for the GNU Emacs text editor @ 2021-12-02 12:06 UTC (permalink / raw)
  To: Philip Kaludercic
  Cc: fatiparty--- via Users list for the GNU Emacs text editor,
	Lars Ingebrigtsen

Dec 2, 2021, 09:17 by philipk@posteo.net:

> fatiparty--- via Users list for the GNU Emacs text editor
> <help-gnu-emacs@gnu.org> writes:
>
>> Dec 2, 2021, 08:31 by larsi@gnus.org:
>>
>>> fatiparty--- via Users list for the GNU Emacs text editor
>>> <help-gnu-emacs@gnu.org> writes:
>>>
>>>> Is there a way to display the line number on each buffer line?
>>>>
>>>
>>> `M-x display-line-numbers-mode'
>>>
>> That's what I was looking for.  Is there a technique for changing the foreground colour of the line number as well?
>>
>
> You can customise the faces line-number (for all lines) and
> line-number-current-line (for the current line).  Use `M-x
> customize-face [face name]' to do this interactively.
>

That is good, but I want to do that from my init file if possible.  Is there a way to reduce the line number size as well?



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

* Re: Display line number on each buffer line
  2021-12-02 12:06       ` fatiparty--- via Users list for the GNU Emacs text editor
@ 2021-12-02 13:33         ` Alejandro Barocio A.
  2021-12-02 14:39           ` fatiparty--- via Users list for the GNU Emacs text editor
  2021-12-02 14:53         ` Michael Heerdegen
  2021-12-02 20:42         ` Philip Kaludercic
  2 siblings, 1 reply; 14+ messages in thread
From: Alejandro Barocio A. @ 2021-12-02 13:33 UTC (permalink / raw)
  To: help-gnu-emacs

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


fatiparty--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> writes:

> Dec 2, 2021, 09:17 by philipk@posteo.net:
>
>> fatiparty--- via Users list for the GNU Emacs text editor
>> <help-gnu-emacs@gnu.org> writes:
>>
>>> Dec 2, 2021, 08:31 by larsi@gnus.org:
>>>
>>>> fatiparty--- via Users list for the GNU Emacs text editor
>>>> <help-gnu-emacs@gnu.org> writes:
>>>>
>>>>> Is there a way to display the line number on each buffer line?
>>>>>
>>>>
>>>> `M-x display-line-numbers-mode'
>>>>
>>> That's what I was looking for.  Is there a technique for changing the foreground colour of the line number as well?
>>>
>>
>> You can customise the faces line-number (for all lines) and
>> line-number-current-line (for the current line).  Use `M-x
>> customize-face [face name]' to do this interactively.
>>
>
> That is good, but I want to do that from my init file if possible.  Is
> there a way to reduce the line number size as well?

All configuration and customization could be done from your init.el.

All customization that changes font, sizes, colours... all is done
customizing your faces.

-- 
Alejandro Barocio A.
Ex nihilo nihil fit.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

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

* Display line number on each buffer line
  2021-12-02 13:33         ` Alejandro Barocio A.
@ 2021-12-02 14:39           ` fatiparty--- via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 14+ messages in thread
From: fatiparty--- via Users list for the GNU Emacs text editor @ 2021-12-02 14:39 UTC (permalink / raw)
  To: Alejandro Barocio A.; +Cc: Help Gnu Emacs


Dec 2, 2021, 13:33 by abarocio80@gmail.com:

>
> fatiparty--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> writes:
>
>> Dec 2, 2021, 09:17 by philipk@posteo.net:
>>
>>> fatiparty--- via Users list for the GNU Emacs text editor
>>> <help-gnu-emacs@gnu.org> writes:
>>>
>>>> Dec 2, 2021, 08:31 by larsi@gnus.org:
>>>>
>>>>> fatiparty--- via Users list for the GNU Emacs text editor
>>>>> <help-gnu-emacs@gnu.org> writes:
>>>>>
>>>>>> Is there a way to display the line number on each buffer line?
>>>>>>
>>>>>
>>>>> `M-x display-line-numbers-mode'
>>>>>
>>>> That's what I was looking for.  Is there a technique for changing the foreground colour of the line number as well?
>>>>
>>>
>>> You can customise the faces line-number (for all lines) and
>>> line-number-current-line (for the current line).  Use `M-x
>>> customize-face [face name]' to do this interactively.
>>>
>>
>> That is good, but I want to do that from my init file if possible.  Is
>> there a way to reduce the line number size as well?
>>
>
> All configuration and customization could be done from your init.el.
>
> All customization that changes font, sizes, colours... all is done
> customizing your faces.
>
What are the keyword names I need to change exactly in my init file?  



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

* Re: Display line number on each buffer line
  2021-12-02 12:06       ` fatiparty--- via Users list for the GNU Emacs text editor
  2021-12-02 13:33         ` Alejandro Barocio A.
@ 2021-12-02 14:53         ` Michael Heerdegen
  2021-12-02 15:09           ` Eli Zaretskii
  2021-12-02 20:42         ` Philip Kaludercic
  2 siblings, 1 reply; 14+ messages in thread
From: Michael Heerdegen @ 2021-12-02 14:53 UTC (permalink / raw)
  To: help-gnu-emacs

fatiparty--- via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> That is good, but I want to do that from my init file if possible.  Is
> there a way to reduce the line number size as well?

You can call `face-spec-set' to change the default appearance of a face,
e.g.

#+begin_src emacs-lisp
(face-spec-set 'line-number
               '((t (:foreground "red" :height .6)))
               'face-defface-spec)
#+end_src

The face spec is the same thing as in face definitions.

Michael.




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

* Re: Display line number on each buffer line
  2021-12-02 14:53         ` Michael Heerdegen
@ 2021-12-02 15:09           ` Eli Zaretskii
  2021-12-02 15:23             ` Michael Heerdegen
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2021-12-02 15:09 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Michael Heerdegen <michael_heerdegen@web.de>
> Date: Thu, 02 Dec 2021 15:53:27 +0100
> 
> You can call `face-spec-set' to change the default appearance of a face,
> e.g.
> 
> #+begin_src emacs-lisp
> (face-spec-set 'line-number
>                '((t (:foreground "red" :height .6)))
>                'face-defface-spec)
> #+end_src

In general, set-face-attribute is the recommended method of changing
attributes of faces.



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

* Re: Display line number on each buffer line
  2021-12-02 15:09           ` Eli Zaretskii
@ 2021-12-02 15:23             ` Michael Heerdegen
  2021-12-03  9:36               ` fatiparty--- via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Heerdegen @ 2021-12-02 15:23 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

> > #+begin_src emacs-lisp
> > (face-spec-set 'line-number
> >                '((t (:foreground "red" :height .6)))
> >                'face-defface-spec)
> > #+end_src
>
> In general, set-face-attribute is the recommended method of changing
> attributes of faces.

Thanks for that clarification.

I am using different color themes, light and dark ones, and AFAIR this
is the reason why I prefer a complete redefinition as above instead of
`set-face-attribute' calls.

Michael.




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

* Re: Display line number on each buffer line
  2021-12-02 12:06       ` fatiparty--- via Users list for the GNU Emacs text editor
  2021-12-02 13:33         ` Alejandro Barocio A.
  2021-12-02 14:53         ` Michael Heerdegen
@ 2021-12-02 20:42         ` Philip Kaludercic
  2 siblings, 0 replies; 14+ messages in thread
From: Philip Kaludercic @ 2021-12-02 20:42 UTC (permalink / raw)
  To: fatiparty--- via Users list for the GNU Emacs text editor
  Cc: fatiparty, Lars Ingebrigtsen

fatiparty--- via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> Dec 2, 2021, 09:17 by philipk@posteo.net:
>
>> fatiparty--- via Users list for the GNU Emacs text editor
>> <help-gnu-emacs@gnu.org> writes:
>>
>>> Dec 2, 2021, 08:31 by larsi@gnus.org:
>>>
>>>> fatiparty--- via Users list for the GNU Emacs text editor
>>>> <help-gnu-emacs@gnu.org> writes:
>>>>
>>>>> Is there a way to display the line number on each buffer line?
>>>>>
>>>>
>>>> `M-x display-line-numbers-mode'
>>>>
>>> That's what I was looking for.  Is there a technique for changing the foreground colour of the line number as well?
>>>
>>
>> You can customise the faces line-number (for all lines) and
>> line-number-current-line (for the current line).  Use `M-x
>> customize-face [face name]' to do this interactively.
>>
>
> That is good, but I want to do that from my init file if possible.  Is there a way to reduce the line number size as well?

Something like this should be enough:

--8<---------------cut here---------------start------------->8---
(set-face-background 'line-number "red")
(set-face-foreground 'line-number-current-line "blue")
--8<---------------cut here---------------end--------------->8---

-- 
	Philip Kaludercic



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

* Display line number on each buffer line
  2021-12-02 15:23             ` Michael Heerdegen
@ 2021-12-03  9:36               ` fatiparty--- via Users list for the GNU Emacs text editor
  2021-12-03 23:47                 ` Michael Heerdegen
  0 siblings, 1 reply; 14+ messages in thread
From: fatiparty--- via Users list for the GNU Emacs text editor @ 2021-12-03  9:36 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: Help Gnu Emacs


Dec 2, 2021, 15:23 by michael_heerdegen@web.de:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>> > #+begin_src emacs-lisp
>> > (face-spec-set 'line-number
>> >                '((t (:foreground "red" :height .6)))
>> >                'face-defface-spec)
>> > #+end_src
>>
>> In general, set-face-attribute is the recommended method of changing
>> attributes of faces.
>>
>
> Thanks for that clarification.
>
> I am using different color themes, light and dark ones, and AFAIR this
> is the reason why I prefer a complete redefinition as above instead of
> `set-face-attribute' calls.
>
> Michael.
>
I think emacs can distinguish between light and dark background.  How does one adapt
the colours so they are different on light and dark frame backgrounds, for reasons of legibility?




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

* Re: Display line number on each buffer line
  2021-12-02  9:02   ` fatiparty--- via Users list for the GNU Emacs text editor
  2021-12-02  9:17     ` Philip Kaludercic
       [not found]     ` <875ys7z7pl.fsf@posteo.net-MpuQz9y----2>
@ 2021-12-03 20:53     ` Jean Louis
  2 siblings, 0 replies; 14+ messages in thread
From: Jean Louis @ 2021-12-03 20:53 UTC (permalink / raw)
  To: fatiparty
  Cc: Lars Ingebrigtsen,
	fatiparty--- via Users list for the GNU Emacs text editor

* fatiparty--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-12-02 12:04]:
> Dec 2, 2021, 08:31 by larsi@gnus.org:
> 
> > fatiparty--- via Users list for the GNU Emacs text editor
> > <help-gnu-emacs@gnu.org> writes:
> >
> >> Is there a way to display the line number on each buffer line?
> >>
> >
> > `M-x display-line-numbers-mode'
> >
> That's what I was looking for.  Is there a technique for changing
> the foreground colour of the line number as well?

M-x linum-mode 

works well too

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Re: Display line number on each buffer line
  2021-12-03  9:36               ` fatiparty--- via Users list for the GNU Emacs text editor
@ 2021-12-03 23:47                 ` Michael Heerdegen
  0 siblings, 0 replies; 14+ messages in thread
From: Michael Heerdegen @ 2021-12-03 23:47 UTC (permalink / raw)
  To: help-gnu-emacs

fatiparty--- via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> I think emacs can distinguish between light and dark background.  How
> does one adapt the colours so they are different on light and dark
> frame backgrounds, for reasons of legibility?

I do it like this:

(face-spec-set 'line-number
               '((((class color) (background dark))
                  :foreground "red" :height .6)
                 (((class color) (background light))
                  :foreground "tan" :height .6))
               'face-defface-spec)

The syntax of face specs is documented in the manual.

For finding good colors you can either try colors interactively with the
customize interface without saving and then copy the color names.  Also
inheriting from other faces is possible, like this:

(face-spec-set 'line-number
               '((t :inherit font-lock-comment-face))
               'face-defface-spec)

This is more appropriate when defining new faces, though.

If you don't want to rely on the custom save file, and you also don't
want to clobber your init file with face settings, an alternative is to
define your own custom theme - see

  (info "(elisp) Custom Themes")

Michael.




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

end of thread, other threads:[~2021-12-03 23:47 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-02  8:18 Display line number on each buffer line fatiparty--- via Users list for the GNU Emacs text editor
2021-12-02  8:31 ` Lars Ingebrigtsen
     [not found] ` <87mtljmmqh.fsf@gnus.org-MpuGQO3----2>
2021-12-02  9:02   ` fatiparty--- via Users list for the GNU Emacs text editor
2021-12-02  9:17     ` Philip Kaludercic
     [not found]     ` <875ys7z7pl.fsf@posteo.net-MpuQz9y----2>
2021-12-02 12:06       ` fatiparty--- via Users list for the GNU Emacs text editor
2021-12-02 13:33         ` Alejandro Barocio A.
2021-12-02 14:39           ` fatiparty--- via Users list for the GNU Emacs text editor
2021-12-02 14:53         ` Michael Heerdegen
2021-12-02 15:09           ` Eli Zaretskii
2021-12-02 15:23             ` Michael Heerdegen
2021-12-03  9:36               ` fatiparty--- via Users list for the GNU Emacs text editor
2021-12-03 23:47                 ` Michael Heerdegen
2021-12-02 20:42         ` Philip Kaludercic
2021-12-03 20:53     ` Jean Louis

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.