line numbers: finer configuration of line numbers activation
This commit is contained in:
parent
ae9a088d19
commit
a28e17c4d3
|
@ -305,8 +305,20 @@ recenters point when it reaches the top or bottom of the
|
||||||
screen.")
|
screen.")
|
||||||
|
|
||||||
(defvar dotspacemacs-line-numbers nil
|
(defvar dotspacemacs-line-numbers nil
|
||||||
"If non nil line numbers are turned on in all `prog-mode' and `text-mode'
|
"Control line numbers activation.
|
||||||
derivatives. If set to `relative', also turns on relative line numbers.")
|
If set to `t' or `relative' line numbers are turned on in all `prog-mode' and
|
||||||
|
`text-mode' derivatives. If set to `relative', line numbers are relative.
|
||||||
|
This variable can also be set to a property list for finer control:
|
||||||
|
'(:relative nil
|
||||||
|
:disabled-for-modes dired-mode
|
||||||
|
doc-view-mode
|
||||||
|
markdown-mode
|
||||||
|
org-mode
|
||||||
|
pdf-view-mode
|
||||||
|
text-mode
|
||||||
|
:size-limit-kb 1000)
|
||||||
|
The property `:enabled-for-modes' takes priority over `:disabled-for-modes' and
|
||||||
|
restricts line-number to the specified list of major-mode.")
|
||||||
|
|
||||||
(defvar dotspacemacs-persistent-server nil
|
(defvar dotspacemacs-persistent-server nil
|
||||||
"If non nil advises quit functions to keep server open when quitting.")
|
"If non nil advises quit functions to keep server open when quitting.")
|
||||||
|
|
|
@ -252,8 +252,19 @@ values."
|
||||||
;; scrolling overrides the default behavior of Emacs which recenters point
|
;; scrolling overrides the default behavior of Emacs which recenters point
|
||||||
;; when it reaches the top or bottom of the screen. (default t)
|
;; when it reaches the top or bottom of the screen. (default t)
|
||||||
dotspacemacs-smooth-scrolling t
|
dotspacemacs-smooth-scrolling t
|
||||||
;; If non-nil line numbers are turned on in all `prog-mode' and `text-mode'
|
;; Control line numbers activation.
|
||||||
;; derivatives. If set to `relative', also turns on relative line numbers.
|
;; If set to `t' or `relative' line numbers are turned on in all `prog-mode' and
|
||||||
|
;; `text-mode' derivatives. If set to `relative', line numbers are relative.
|
||||||
|
;; This variable can also be set to a property list for finer control:
|
||||||
|
;; '(:relative nil
|
||||||
|
;; :disabled-for-modes dired-mode
|
||||||
|
;; doc-view-mode
|
||||||
|
;; markdown-mode
|
||||||
|
;; org-mode
|
||||||
|
;; pdf-view-mode
|
||||||
|
;; text-mode
|
||||||
|
;; :size-limit-kb 1000)
|
||||||
|
;; See Spacemacs ducumentation (SPC h SPC) for a list of available properties.
|
||||||
;; (default nil)
|
;; (default nil)
|
||||||
dotspacemacs-line-numbers nil
|
dotspacemacs-line-numbers nil
|
||||||
;; Code folding method. Possible values are `evil' and `origami'.
|
;; Code folding method. Possible values are `evil' and `origami'.
|
||||||
|
|
|
@ -1161,6 +1161,43 @@ If it is set to =relative=, line numbers are show in a relative way:
|
||||||
(setq-default dotspacemacs-line-numbers 'relative)
|
(setq-default dotspacemacs-line-numbers 'relative)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
=dotspacemacs-line-numbers= can also be set to a property list for finer control
|
||||||
|
over line numbers activation.
|
||||||
|
|
||||||
|
Available properties:
|
||||||
|
|
||||||
|
| Property | Description |
|
||||||
|
|-----------------------+----------------------------------------------------------------------------------------------|
|
||||||
|
| =:disabled-for-modes= | list of major modes where line numbering is inhibited |
|
||||||
|
| =:enabled-for-modes= | disable for all major modes except those listed. Takes precedence over =:disabled-for-modes= |
|
||||||
|
| =:relative= | if non-nil, line numbers are relative to the position of the cursor |
|
||||||
|
| =:size-limit-kb= | size limit in kilobytes after which line numbers are not activated |
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
Disable line numbers in dired-mode, doc-view-mode, markdown-mode, org-mode,
|
||||||
|
pdf-view-mode, text-mode as well as buffers over 1Mb:
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(setq-default dotspacemacs-lines-numbers '(:relative nil
|
||||||
|
:disabled-for-modes dired-mode
|
||||||
|
doc-view-mode
|
||||||
|
markdown-mode
|
||||||
|
org-mode
|
||||||
|
pdf-view-mode
|
||||||
|
text-mode
|
||||||
|
:size-limit-kb 1000))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
Relative line numbers only in c-mode and c++ mode with a size limit of =dotspacemacs-large-file-size=:
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(setq-default dotspacemacs-lines-numbers '(:relative t
|
||||||
|
:enabled-for-modes c-mode
|
||||||
|
c++-mode
|
||||||
|
:size-limit-kb (* dotspacemacs-large-file-size 1000))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
** Mode-line
|
** Mode-line
|
||||||
The mode line is a heavily customized [[https://github.com/milkypostman/powerline][powerline]] with the following capabilities:
|
The mode line is a heavily customized [[https://github.com/milkypostman/powerline][powerline]] with the following capabilities:
|
||||||
- show the window number
|
- show the window number
|
||||||
|
|
|
@ -1047,3 +1047,25 @@ if prefix argument ARG is given, switch to it in an other, possibly new window."
|
||||||
text-scale-mode-amount) 1)
|
text-scale-mode-amount) 1)
|
||||||
(if (car (window-margins))
|
(if (car (window-margins))
|
||||||
(car (window-margins)) 1)))))
|
(car (window-margins)) 1)))))
|
||||||
|
|
||||||
|
(defun spacemacs/enable-line-numbers-p ()
|
||||||
|
"Return non-nil if line numbers should be enabled for current buffer.
|
||||||
|
Decision is based on `dotspacemacs-line-numbers'."
|
||||||
|
(and dotspacemacs-line-numbers
|
||||||
|
(not (string-match-p "\\*.*\\*" (buffer-name)))
|
||||||
|
(not (and (spacemacs/mplist-get dotspacemacs-line-numbers
|
||||||
|
:size-limit-kb)
|
||||||
|
(> (buffer-size)
|
||||||
|
(* 1000 (car (spacemacs/mplist-get dotspacemacs-line-numbers
|
||||||
|
:size-limit-kb))))))
|
||||||
|
(or (and (spacemacs/mplist-get dotspacemacs-line-numbers
|
||||||
|
:enabled-for-modes)
|
||||||
|
(memq major-mode (spacemacs/mplist-get dotspacemacs-line-numbers
|
||||||
|
:enabled-for-modes)))
|
||||||
|
(and (not (spacemacs/mplist-get dotspacemacs-line-numbers
|
||||||
|
:enabled-for-modes))
|
||||||
|
(spacemacs/mplist-get dotspacemacs-line-numbers
|
||||||
|
:disabled-for-modes)
|
||||||
|
(not (memq major-mode
|
||||||
|
(spacemacs/mplist-get dotspacemacs-line-numbers
|
||||||
|
:disabled-for-modes)))))))
|
||||||
|
|
|
@ -240,9 +240,20 @@
|
||||||
:init (spacemacs/set-leader-keys "ji" 'imenu)))
|
:init (spacemacs/set-leader-keys "ji" 'imenu)))
|
||||||
|
|
||||||
(defun spacemacs-base/init-linum ()
|
(defun spacemacs-base/init-linum ()
|
||||||
(when dotspacemacs-line-numbers
|
(use-package linum
|
||||||
(add-hook 'prog-mode-hook 'linum-mode)
|
:config
|
||||||
(add-hook 'text-mode-hook 'linum-mode))
|
(progn
|
||||||
|
(if (or (eq dotspacemacs-line-numbers t)
|
||||||
|
(eq dotspacemacs-line-numbers 'relative))
|
||||||
|
(progn
|
||||||
|
(add-hook 'prog-mode-hook 'linum-mode)
|
||||||
|
(add-hook 'text-mode-hook 'linum-mode)))
|
||||||
|
(defun linum-on ()
|
||||||
|
"Overwrite the original `linum-on' function with a more selective one."
|
||||||
|
(when (spacemacs/enable-line-numbers-p)
|
||||||
|
(linum-mode)))
|
||||||
|
(when dotspacemacs-line-numbers
|
||||||
|
(global-linum-mode))))
|
||||||
(setq linum-format "%4d")
|
(setq linum-format "%4d")
|
||||||
(spacemacs|add-toggle line-numbers
|
(spacemacs|add-toggle line-numbers
|
||||||
:mode linum-mode
|
:mode linum-mode
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
;;; packages.el --- nlinum Layer packages File
|
||||||
|
;;
|
||||||
|
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
|
||||||
|
;;
|
||||||
|
;; Author: Thomas de Beauchêne <thomas.de.beauchene@gmail.com>
|
||||||
|
;; URL: https://github.com/syl20bnr/spacemacs
|
||||||
|
;;
|
||||||
|
;; This file is not part of GNU Emacs.
|
||||||
|
;;
|
||||||
|
;;; License: GPLv3
|
||||||
|
|
||||||
|
(defun spacemacs/nlinum-maybe-on ()
|
||||||
|
(when (spacemacs/enable-line-numbers-p)
|
||||||
|
(nlinum-mode)))
|
|
@ -20,15 +20,19 @@
|
||||||
(defun nlinum/init-nlinum ()
|
(defun nlinum/init-nlinum ()
|
||||||
(use-package nlinum
|
(use-package nlinum
|
||||||
:init
|
:init
|
||||||
|
(spacemacs|add-toggle line-numbers
|
||||||
|
:mode nlinum-mode
|
||||||
|
:documentation "Show the line numbers."
|
||||||
|
:evil-leader "tn")
|
||||||
|
:config
|
||||||
(progn
|
(progn
|
||||||
(when dotspacemacs-line-numbers
|
(if (or (eq dotspacemacs-line-numbers t)
|
||||||
(add-hook 'prog-mode-hook 'nlinum-mode)
|
(eq dotspacemacs-line-numbers 'relative))
|
||||||
(add-hook 'text-mode-hook 'nlinum-mode))
|
(progn
|
||||||
(setq nlinum-format "%4d")
|
(add-hook 'prog-mode-hook 'nlinum-mode)
|
||||||
(spacemacs|add-toggle line-numbers
|
(add-hook 'text-mode-hook 'nlinum-mode))
|
||||||
:mode nlinum-mode
|
(add-hook 'after-change-major-mode-hook 'spacemacs/nlinum-maybe-on))
|
||||||
:documentation "Show the line numbers."
|
(setq nlinum-format "%4d"))))
|
||||||
:evil-leader "tn"))))
|
|
||||||
|
|
||||||
(defun nlinum/init-nlinum-relative ()
|
(defun nlinum/init-nlinum-relative ()
|
||||||
(use-package nlinum-relative
|
(use-package nlinum-relative
|
||||||
|
@ -37,7 +41,9 @@
|
||||||
(progn
|
(progn
|
||||||
(setq nlinum-relative-current-symbol ""
|
(setq nlinum-relative-current-symbol ""
|
||||||
nlinum-relative-redisplay-delay 0)
|
nlinum-relative-redisplay-delay 0)
|
||||||
(when (eq dotspacemacs-line-numbers 'relative)
|
(when (or (car (spacemacs/mplist-get dotspacemacs-line-numbers
|
||||||
|
:relative))
|
||||||
|
(eq dotspacemacs-line-numbers 'relative))
|
||||||
(nlinum-relative-setup-evil)
|
(nlinum-relative-setup-evil)
|
||||||
(add-hook 'nlinum-mode-hook 'nlinum-relative-on))
|
(add-hook 'nlinum-mode-hook 'nlinum-relative-on))
|
||||||
(spacemacs/set-leader-keys "tr" 'nlinum-relative-toggle))))
|
(spacemacs/set-leader-keys "tr" 'nlinum-relative-toggle))))
|
||||||
|
|
|
@ -259,12 +259,13 @@
|
||||||
:commands (linum-relative-toggle linum-relative-on)
|
:commands (linum-relative-toggle linum-relative-on)
|
||||||
:init
|
:init
|
||||||
(progn
|
(progn
|
||||||
(when (eq dotspacemacs-line-numbers 'relative)
|
(when (or (eq dotspacemacs-line-numbers 'relative)
|
||||||
(linum-relative-on))
|
(car (spacemacs/mplist-get dotspacemacs-line-numbers
|
||||||
|
:relative)))
|
||||||
|
(add-hook 'spacemacs-post-user-config-hook 'linum-relative-on))
|
||||||
(spacemacs/set-leader-keys "tr" 'spacemacs/linum-relative-toggle))
|
(spacemacs/set-leader-keys "tr" 'spacemacs/linum-relative-toggle))
|
||||||
:config
|
:config
|
||||||
(progn
|
(setq linum-relative-current-symbol "")))
|
||||||
(setq linum-relative-current-symbol ""))))
|
|
||||||
|
|
||||||
(defun spacemacs-evil/init-vi-tilde-fringe ()
|
(defun spacemacs-evil/init-vi-tilde-fringe ()
|
||||||
(spacemacs|do-after-display-system-init
|
(spacemacs|do-after-display-system-init
|
||||||
|
|
Loading…
Reference in New Issue