aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/cus-start.el32
-rw-r--r--lisp/faces.el27
-rw-r--r--lisp/frame.el4
-rw-r--r--lisp/menu-bar.el19
-rw-r--r--lisp/simple.el21
5 files changed, 98 insertions, 5 deletions
diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index 744fe7f69ee..017e7f9fa55 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -584,6 +584,38 @@ since it could result in memory overflow and make Emacs crash."
584 (const :tag "Grow only" :value grow-only)) 584 (const :tag "Grow only" :value grow-only))
585 "25.1") 585 "25.1")
586 (display-raw-bytes-as-hex display boolean "26.1") 586 (display-raw-bytes-as-hex display boolean "26.1")
587 (display-line-numbers display
588 (choice
589 (const :tag "Off (nil)" :value nil)
590 (const :tag "Absolute line numbers"
591 :value t)
592 (const :tag "Relative line numbers"
593 :value relative)
594 (const :tag "Visually relative line numbers"
595 :value visual))
596 "26.1")
597 (display-line-number-width display
598 (choice
599 (const :tag "Dynamically computed"
600 :value nil)
601 (integer :menu-tag "Fixed number of columns"
602 :value 2
603 :format "%v"))
604 "26.1")
605 (display-line-numbers-current-absolute display
606 (choice
607 (const :tag "Display actual number of current line"
608 :value t)
609 (const :tag "Display zero as number of current line"
610 :value nil))
611 "26.1")
612 (display-line-numbers-widen display
613 (choice
614 (const :tag "Disregard narrowing when calculating line numbers"
615 :value t)
616 (const :tag "Count lines from beinning of narrowed region"
617 :value nil))
618 "26.1")
587 ;; xfaces.c 619 ;; xfaces.c
588 (scalable-fonts-allowed display boolean "22.1") 620 (scalable-fonts-allowed display boolean "22.1")
589 ;; xfns.c 621 ;; xfns.c
diff --git a/lisp/faces.el b/lisp/faces.el
index 9a8a1344caf..c3693d16631 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -2465,6 +2465,33 @@ If you set `term-file-prefix' to nil, this function does nothing."
2465 :version "21.1" 2465 :version "21.1"
2466 :group 'basic-faces) 2466 :group 'basic-faces)
2467 2467
2468;; Definition stolen from linum.el.
2469(defface line-number
2470 '((t :inherit (shadow default)))
2471 "Face for displaying line numbers.
2472This face is used when `display-line-numbers' is non-nil.
2473
2474If you customize the font of this face, make sure it is a
2475monospaced font, otherwise line numbers will not line up,
2476and text lines might move horizontally as you move through
2477the buffer."
2478 :version "26.1"
2479 :group 'basic-faces)
2480
2481(defface line-number-current-line
2482 '((t :inherit line-number))
2483 "Face for displaying the current line number.
2484This face is used when `display-line-numbers' is non-nil.
2485
2486If you customize the font of this face, make sure it is a
2487monospaced font, otherwise line numbers will not line up,
2488and text lines might move horizontally as you move through
2489the buffer. Similarly, making this face's font different
2490from that of the `line-number' face could produce such
2491unwanted effects."
2492 :version "26.1"
2493 :group 'basic-faces)
2494
2468(defface escape-glyph 2495(defface escape-glyph
2469 '((((background dark)) :foreground "cyan") 2496 '((((background dark)) :foreground "cyan")
2470 ;; See the comment in minibuffer-prompt for 2497 ;; See the comment in minibuffer-prompt for
diff --git a/lisp/frame.el b/lisp/frame.el
index b54df6fa160..c629a9497c0 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -2466,6 +2466,10 @@ See also `toggle-frame-maximized'."
2466 line-prefix 2466 line-prefix
2467 wrap-prefix 2467 wrap-prefix
2468 truncate-lines 2468 truncate-lines
2469 display-line-numbers
2470 display-line-number-width
2471 display-line-numbers-current-absolute
2472 display-line-numbers-widen
2469 bidi-paragraph-direction 2473 bidi-paragraph-direction
2470 bidi-display-reordering)) 2474 bidi-display-reordering))
2471 2475
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 9c7bcffbaab..06f8c7872b7 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -1101,17 +1101,32 @@ The selected font will be the default on both the existing and future frames."
1101 :button (:radio . (eq tool-bar-mode nil)))) 1101 :button (:radio . (eq tool-bar-mode nil))))
1102 menu))) 1102 menu)))
1103 1103
1104(defun toggle-display-line-numbers ()
1105 (interactive)
1106 (if display-line-numbers
1107 (setq display-line-numbers nil)
1108 (setq display-line-numbers t))
1109 (force-mode-line-update))
1110
1104(defvar menu-bar-showhide-menu 1111(defvar menu-bar-showhide-menu
1105 (let ((menu (make-sparse-keymap "Show/Hide"))) 1112 (let ((menu (make-sparse-keymap "Show/Hide")))
1106 1113
1114 (bindings--define-key menu [display-line-numbers]
1115 `(menu-item "Line Numbers for all lines"
1116 ,(lambda ()
1117 (interactive)
1118 (toggle-display-line-numbers))
1119 :help "Show the line number alongside each line"
1120 :button (:toggle . display-line-numbers)))
1121
1107 (bindings--define-key menu [column-number-mode] 1122 (bindings--define-key menu [column-number-mode]
1108 (menu-bar-make-mm-toggle column-number-mode 1123 (menu-bar-make-mm-toggle column-number-mode
1109 "Column Numbers" 1124 "Column Numbers in Mode Line"
1110 "Show the current column number in the mode line")) 1125 "Show the current column number in the mode line"))
1111 1126
1112 (bindings--define-key menu [line-number-mode] 1127 (bindings--define-key menu [line-number-mode]
1113 (menu-bar-make-mm-toggle line-number-mode 1128 (menu-bar-make-mm-toggle line-number-mode
1114 "Line Numbers" 1129 "Line Numbers in Mode Line"
1115 "Show the current line number in the mode line")) 1130 "Show the current line number in the mode line"))
1116 1131
1117 (bindings--define-key menu [size-indication-mode] 1132 (bindings--define-key menu [size-indication-mode]
diff --git a/lisp/simple.el b/lisp/simple.el
index 1db14a859d6..3d23fc35596 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -5942,6 +5942,10 @@ columns by which window is scrolled from left margin.
5942When the `track-eol' feature is doing its job, the value is 5942When the `track-eol' feature is doing its job, the value is
5943`most-positive-fixnum'.") 5943`most-positive-fixnum'.")
5944 5944
5945(defvar last--line-number-width 0
5946 "Last value of width used for displaying line numbers.
5947Used internally by `line-move-visual'.")
5948
5945(defcustom line-move-ignore-invisible t 5949(defcustom line-move-ignore-invisible t
5946 "Non-nil means commands that move by lines ignore invisible newlines. 5950 "Non-nil means commands that move by lines ignore invisible newlines.
5947When this option is non-nil, \\[next-line], \\[previous-line], \\[move-end-of-line], and \\[move-beginning-of-line] behave 5951When this option is non-nil, \\[next-line], \\[previous-line], \\[move-end-of-line], and \\[move-beginning-of-line] behave
@@ -6212,6 +6216,7 @@ not vscroll."
6212If NOERROR, don't signal an error if we can't move that many lines." 6216If NOERROR, don't signal an error if we can't move that many lines."
6213 (let ((opoint (point)) 6217 (let ((opoint (point))
6214 (hscroll (window-hscroll)) 6218 (hscroll (window-hscroll))
6219 (lnum-width (line-number-display-width t))
6215 target-hscroll) 6220 target-hscroll)
6216 ;; Check if the previous command was a line-motion command, or if 6221 ;; Check if the previous command was a line-motion command, or if
6217 ;; we were called from some other command. 6222 ;; we were called from some other command.
@@ -6219,9 +6224,19 @@ If NOERROR, don't signal an error if we can't move that many lines."
6219 (memq last-command `(next-line previous-line ,this-command))) 6224 (memq last-command `(next-line previous-line ,this-command)))
6220 ;; If so, there's no need to reset `temporary-goal-column', 6225 ;; If so, there's no need to reset `temporary-goal-column',
6221 ;; but we may need to hscroll. 6226 ;; but we may need to hscroll.
6222 (if (or (/= (cdr temporary-goal-column) hscroll) 6227 (progn
6223 (> (cdr temporary-goal-column) 0)) 6228 (if (or (/= (cdr temporary-goal-column) hscroll)
6224 (setq target-hscroll (cdr temporary-goal-column))) 6229 (> (cdr temporary-goal-column) 0))
6230 (setq target-hscroll (cdr temporary-goal-column)))
6231 ;; Update the COLUMN part of temporary-goal-column if the
6232 ;; line-number display changed its width since the last
6233 ;; time.
6234 (setq temporary-goal-column
6235 (cons (+ (car temporary-goal-column)
6236 (/ (float (- lnum-width last--line-number-width))
6237 (frame-char-width)))
6238 (cdr temporary-goal-column)))
6239 (setq last--line-number-width lnum-width))
6225 ;; Otherwise, we should reset `temporary-goal-column'. 6240 ;; Otherwise, we should reset `temporary-goal-column'.
6226 (let ((posn (posn-at-point)) 6241 (let ((posn (posn-at-point))
6227 x-pos) 6242 x-pos)