💥 Drop Emacs 25.x support
Emacs 26.1 is Doom's new minimum supported version Closes #2026
This commit is contained in:
parent
9cb535043c
commit
99cd52e70f
33 changed files with 48 additions and 426 deletions
|
@ -1,92 +0,0 @@
|
|||
;;; core/autoload/line-numbers.el -*- lexical-binding: t; -*-
|
||||
;;;###if (version< emacs-version "26.1")
|
||||
|
||||
;; DEPRECATED This was lifted out of the display-line-numbers library in Emacs
|
||||
;; 26.1 and modified to use nlinum for Emacs 25.x users. It should be removed
|
||||
;; should Emacs 25 support be removed.
|
||||
|
||||
;;;###autoload
|
||||
(defvar display-line-numbers t
|
||||
"Non-nil means display line numbers.
|
||||
|
||||
If the value is t, display the absolute number of each line of a buffer
|
||||
shown in a window. Absolute line numbers count from the beginning of
|
||||
the current narrowing, or from buffer beginning. If the value is
|
||||
relative, display for each line not containing the window's point its
|
||||
relative number instead, i.e. the number of the line relative to the
|
||||
line showing the window's point.
|
||||
|
||||
In either case, line numbers are displayed at the beginning of each
|
||||
non-continuation line that displays buffer text, i.e. after each newline
|
||||
character that comes from the buffer. The value visual is like
|
||||
relative but counts screen lines instead of buffer lines. In practice
|
||||
this means that continuation lines count as well when calculating the
|
||||
relative number of a line.
|
||||
|
||||
Lisp programs can disable display of a line number of a particular
|
||||
buffer line by putting the display-line-numbers-disable text property
|
||||
or overlay property on the first visible character of that line.")
|
||||
|
||||
(defgroup display-line-numbers nil "Display line number preferences"
|
||||
:group 'emacs)
|
||||
|
||||
;;;###autoload
|
||||
(defcustom display-line-numbers-type t
|
||||
"The default type of line numbers to use in `display-line-numbers-mode'.
|
||||
See `display-line-numbers' for value options."
|
||||
:type '(choice (const :tag "Relative line numbers" relative)
|
||||
(const :tag "Relative visual line numbers" visual)
|
||||
(other :tag "Absolute line numbers" t)))
|
||||
|
||||
;;;###autoload
|
||||
(defcustom display-line-numbers-grow-only nil
|
||||
"If non-nil, do not shrink line number width."
|
||||
:type 'boolean)
|
||||
|
||||
;;;###autoload
|
||||
(defcustom display-line-numbers-width-start nil
|
||||
"If non-nil, count number of lines to use for line number width.
|
||||
When `display-line-numbers-mode' is turned on,
|
||||
`display-line-numbers-width' is set to the minimum width necessary
|
||||
to display all line numbers in the buffer."
|
||||
:type 'boolean)
|
||||
|
||||
;;;###autoload
|
||||
(defun line-number-display-width (&optional _)
|
||||
"Return the width used for displaying line numbers in the
|
||||
selected window."
|
||||
(length (save-excursion (goto-char (point-max))
|
||||
(format-mode-line "%l"))))
|
||||
|
||||
(defun display-line-numbers-update-width ()
|
||||
"Prevent the line number width from shrinking."
|
||||
(let ((width (line-number-display-width)))
|
||||
(when (> width (or display-line-numbers-width 1))
|
||||
(setq display-line-numbers-width width))))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode display-line-numbers-mode
|
||||
"Toggle display of line numbers in the buffer.
|
||||
This uses `display-line-numbers' internally.
|
||||
|
||||
To change the type of line numbers displayed by default,
|
||||
customize `display-line-numbers-type'. To change the type while
|
||||
the mode is on, set `display-line-numbers' directly."
|
||||
:lighter nil
|
||||
(cond ((null display-line-numbers-type))
|
||||
((eq display-line-numbers-type 'relative)
|
||||
(if display-line-numbers-mode
|
||||
(nlinum-relative-off)
|
||||
(nlinum-relative-on)))
|
||||
((nlinum-mode (if display-line-numbers-mode +1 -1)))))
|
||||
|
||||
(defun display-line-numbers--turn-on ()
|
||||
"Turn on `display-line-numbers-mode'."
|
||||
(unless (or (minibufferp)
|
||||
;; taken from linum.el
|
||||
(and (daemonp) (null (frame-parameter nil 'client))))
|
||||
(display-line-numbers-mode)))
|
||||
|
||||
;;;###autoload
|
||||
(define-globalized-minor-mode global-display-line-numbers-mode
|
||||
display-line-numbers-mode display-line-numbers--turn-on)
|
|
@ -117,8 +117,7 @@ If DIR is not a project, it will be indexed (but not cached)."
|
|||
#'projectile-find-file)))
|
||||
((fboundp 'counsel-file-jump) ; ivy only
|
||||
(call-interactively #'counsel-file-jump))
|
||||
((and (fboundp 'project-find-file-in) ; emacs 26.1+ only
|
||||
(project-current))
|
||||
((project-current)
|
||||
(project-find-file-in nil (list default-directory) nil))
|
||||
((fboundp 'helm-find-files)
|
||||
(call-interactively #'helm-find-files))
|
||||
|
|
|
@ -72,21 +72,14 @@ visual-line-mode is on, this skips relative and uses visual instead.
|
|||
See `display-line-numbers' for what these values mean."
|
||||
(interactive)
|
||||
(defvar doom--line-number-style display-line-numbers-type)
|
||||
;; DEPRECATED
|
||||
(let* ((styles `(t ,(if (and EMACS26+ visual-line-mode) 'visual 'relative) nil))
|
||||
(let* ((styles `(t ,(if visual-line-mode 'visual 'relative) nil))
|
||||
(order (cons display-line-numbers-type (remq display-line-numbers-type styles)))
|
||||
(queue (memq doom--line-number-style order))
|
||||
(next (if (= (length queue) 1)
|
||||
(car order)
|
||||
(car (cdr queue)))))
|
||||
(setq doom--line-number-style next)
|
||||
;; DEPRECATED
|
||||
(if EMACS26+
|
||||
(setq display-line-numbers next)
|
||||
(pcase next
|
||||
(`t (nlinum-relative-off) (nlinum-mode +1))
|
||||
(`relative (nlinum-relative-on))
|
||||
(`nil (nlinum-mode -1))))
|
||||
(setq display-line-numbers next)
|
||||
(message "Switched to %s line numbers"
|
||||
(pcase next
|
||||
(`t "normal")
|
||||
|
|
|
@ -3,41 +3,6 @@
|
|||
(require 'cl-lib)
|
||||
(require 'subr-x)
|
||||
|
||||
;; DEPRECATED Polyfills
|
||||
(unless EMACS26+
|
||||
(with-no-warnings
|
||||
;; `kill-current-buffer' was introduced in Emacs 26
|
||||
(defalias 'kill-current-buffer #'kill-this-buffer)
|
||||
;; if-let and when-let were moved to (if|when)-let* in Emacs 26+ so we alias
|
||||
;; them for 25 users.
|
||||
(defalias 'if-let* #'if-let)
|
||||
(defalias 'when-let* #'when-let)
|
||||
|
||||
;; `mapcan' was introduced in 26.1. `cl-mapcan' isn't a perfect replacement,
|
||||
;; but it's close enough.
|
||||
(defalias 'mapcan #'cl-mapcan)
|
||||
|
||||
(defun alist-get (key alist &optional default remove testfn)
|
||||
"Return the value associated with KEY in ALIST.
|
||||
If KEY is not found in ALIST, return DEFAULT.
|
||||
Use TESTFN to lookup in the alist if non-nil. Otherwise, use `assq'.
|
||||
|
||||
This is a generalized variable suitable for use with `setf'.
|
||||
When using it to set a value, optional argument REMOVE non-nil
|
||||
means to remove KEY from ALIST if the new value is `eql' to DEFAULT."
|
||||
(ignore remove) ;;Silence byte-compiler.
|
||||
(let ((x (if (not testfn)
|
||||
(assq key alist)
|
||||
;; In Emacs<26, `assoc' has no testfn arg, so we have to
|
||||
;; implement it ourselves
|
||||
(if testfn
|
||||
(cl-loop for entry in alist
|
||||
if (funcall testfn key entry)
|
||||
return entry)
|
||||
(assoc key alist)))))
|
||||
(if x (cdr x) default)))))
|
||||
|
||||
|
||||
;;
|
||||
;;; Helpers
|
||||
|
||||
|
|
|
@ -512,79 +512,6 @@ treat Emacs as a non-application window."
|
|||
(defun doom-enable-line-numbers-h () (display-line-numbers-mode +1))
|
||||
(defun doom-disable-line-numbers-h () (display-line-numbers-mode -1))
|
||||
|
||||
;; DEPRECATED `nlinum' is used for Emacs 25 users; 26+ has native line numbers.
|
||||
(use-package! nlinum
|
||||
;; Line number column. A faster (or equivalent, in the worst case) line number
|
||||
;; plugin than `linum-mode'.
|
||||
:unless EMACS26+
|
||||
:defer t
|
||||
:init
|
||||
(defvar doom-line-number-lpad 4
|
||||
"How much padding to place before line numbers.")
|
||||
(defvar doom-line-number-rpad 1
|
||||
"How much padding to place after line numbers.")
|
||||
(defvar doom-line-number-pad-char 32
|
||||
"Character to use for padding line numbers.
|
||||
|
||||
By default, this is a space character. If you use `whitespace-mode' with
|
||||
`space-mark', the whitespace in line numbers will be affected (this can look
|
||||
ugly). In this case, you can change this to ?\u2002, which is a unicode
|
||||
character that looks like a space that `whitespace-mode' won't affect.")
|
||||
:config
|
||||
(setq nlinum-highlight-current-line t)
|
||||
|
||||
;; Fix lingering hl-line overlays (caused by nlinum)
|
||||
(add-hook! 'hl-line-mode-hook
|
||||
(remove-overlays (point-min) (point-max) 'face 'hl-line))
|
||||
|
||||
(defun doom-nlinum-format-fn (line _width)
|
||||
"A more customizable `nlinum-format-function'. See `doom-line-number-lpad',
|
||||
`doom-line-number-rpad' and `doom-line-number-pad-char'. Allows a fix for
|
||||
`whitespace-mode' space-marks appearing inside the line number."
|
||||
(let ((str (number-to-string line)))
|
||||
(setq str (concat (make-string (max 0 (- doom-line-number-lpad (length str)))
|
||||
doom-line-number-pad-char)
|
||||
str
|
||||
(make-string doom-line-number-rpad doom-line-number-pad-char)))
|
||||
(put-text-property 0 (length str) 'face
|
||||
(if (and nlinum-highlight-current-line
|
||||
(= line nlinum--current-line))
|
||||
'nlinum-current-line
|
||||
'linum)
|
||||
str)
|
||||
str))
|
||||
(setq nlinum-format-function #'doom-nlinum-format-fn)
|
||||
|
||||
(add-hook! 'nlinum-mode-hook
|
||||
(defun doom-init-nlinum-width-h ()
|
||||
"Calculate line number column width beforehand (optimization)."
|
||||
(setq nlinum--width
|
||||
(length (save-excursion (goto-char (point-max))
|
||||
(format-mode-line "%l")))))))
|
||||
|
||||
(use-package! nlinum-hl
|
||||
;; Fixes disappearing line numbers in nlinum and other quirks
|
||||
:unless EMACS26+
|
||||
:after nlinum
|
||||
:config
|
||||
;; With `markdown-fontify-code-blocks-natively' enabled in `markdown-mode',
|
||||
;; line numbers tend to vanish next to code blocks.
|
||||
(advice-add #'markdown-fontify-code-block-natively
|
||||
:after #'nlinum-hl-do-markdown-fontify-region)
|
||||
;; When using `web-mode's code-folding an entire range of line numbers will
|
||||
;; vanish in the affected area.
|
||||
(advice-add #'web-mode-fold-or-unfold :after #'nlinum-hl-do-generic-flush)
|
||||
;; Changing fonts can leave nlinum line numbers in their original size; this
|
||||
;; forces them to resize.
|
||||
(add-hook 'after-setting-font-hook #'nlinum-hl-flush-all-windows))
|
||||
|
||||
(use-package! nlinum-relative
|
||||
:unless EMACS26+
|
||||
:defer t
|
||||
:config
|
||||
(setq nlinum-format " %d ")
|
||||
(add-hook 'evil-mode-hook #'nlinum-relative-setup-evil))
|
||||
|
||||
|
||||
;;
|
||||
;;; Theme & font
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
;;; core.el --- the heart of the beast -*- lexical-binding: t; -*-
|
||||
|
||||
(when (version< emacs-version "25.3")
|
||||
(error "Detected Emacs %s. Doom only supports Emacs 25.3 and higher"
|
||||
(when (version< emacs-version "26.1")
|
||||
(error "Detected Emacs %s. Doom only supports Emacs 26.1 and higher"
|
||||
emacs-version))
|
||||
|
||||
(defconst doom-version "2.0.9"
|
||||
"Current version of Doom Emacs.")
|
||||
|
||||
(defconst EMACS26+ (> emacs-major-version 25))
|
||||
(defconst EMACS27+ (> emacs-major-version 26))
|
||||
(defconst IS-MAC (eq system-type 'darwin))
|
||||
(defconst IS-LINUX (eq system-type 'gnu/linux))
|
||||
|
|
|
@ -9,12 +9,6 @@
|
|||
(package! all-the-icons)
|
||||
(package! hide-mode-line)
|
||||
(package! highlight-numbers)
|
||||
;; Some early 26.x builds of Emacs do not have `display-line-numbers' yet, so
|
||||
;; check for it instead of Emacs' version.
|
||||
(unless (locate-library "display-line-numbers")
|
||||
(package! nlinum)
|
||||
(package! nlinum-hl)
|
||||
(package! nlinum-relative))
|
||||
(package! rainbow-delimiters)
|
||||
(package! restart-emacs)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue