Emacs: Use column-number-mode in prog-mode / text-mode only

master
Pierre Neidhardt 2017-06-24 10:04:27 +01:00
parent cbd21d7fa1
commit a9efecbe97
2 changed files with 19 additions and 14 deletions

View File

@ -408,15 +408,20 @@ This does not interfere with `subword-mode'."
(modify-syntax-entry ?_ "_")
(message "_ is a word delimiter")))
(defun turn-on-column-number-mode ()
"Unconditionally turn on `column-number-mode' for the current buffer."
(set (make-variable-buffer-local 'column-number-mode) t))
(defun turn-on-delete-trailing-whitespace ()
"Add the `delete-trailing-whitespace' function to `before-save-hook'.
This does not affect .csv files."
(unless (string= (file-name-extension buffer-file-name) "csv")
(add-hook 'before-save-hook 'delete-trailing-whitespace nil t)))
(defun turn-on-fmt-before-save ()
"Unconditionally add the `fmt' function to `before-save-hook'."
(add-hook 'before-save-hook 'fmt nil t))
(defun turn-on-delete-trailing-whitespace ()
"Unconditionally add the `delete-trailing-whitespace' function to `before-save-hook'."
(unless (string= (file-name-extension buffer-file-name) "csv")
(add-hook 'before-save-hook 'delete-trailing-whitespace nil t)))
(defun turn-off-indent-tabs ()
"Unconditionally turn off tab indentation."
(setq indent-tabs-mode nil))
@ -425,6 +430,14 @@ This does not interfere with `subword-mode'."
"Unconditionally turn on tab indentation."
(setq indent-tabs-mode t))
(defun turn-off-line-number-mode ()
"Unconditionally turn off `line-number-mode' fur the current buffer.."
(set (make-variable-buffer-local 'line-number-mode) nil))
(defun turn-off-linum ()
"Unconditionally turn off Linum mode."
(linum-mode 0))
(defun turn-on-newline-paragraph ()
"Unconditionally make of newlines the start of a paragraph."
(set (make-local-variable 'paragraph-start) "
@ -437,10 +450,6 @@ This does not interfere with `subword-mode'."
"Allow skeletons to make markers to ease field navigation."
(add-hook 'skeleton-end-hook 'skeleton-make-markers))
(defun turn-off-linum ()
"Unconditionally turn off Linum mode."
(linum-mode 0))
(defun turn-on-tab-width-to-4 ()
"Unconditionally set tab width to 4."
(setq tab-width 4))

View File

@ -47,9 +47,6 @@
;;; Enable all disabled commands.
(setq disabled-command-function nil)
;;; Print column number in mode line.
(column-number-mode 1)
;;; Print buffer size in mode line.
(size-indication-mode 1)
@ -69,9 +66,8 @@
;;; Line numbers
;;; Adding to `find-file-hook' ensures it will work for every file, regardless of
;;; the mode, but it won't work for buffers without files nor on mode change.
(defun turn-off-line-number-mode ()
(line-number-mode -1))
(dolist (hook '(prog-mode-hook text-mode-hook))
(add-hook hook 'turn-on-column-number-mode)
(add-hook hook 'turn-off-line-number-mode)
(add-hook hook 'linum-mode))
;;; Emacs-nox does not display a fringe after the linum: Setting linum-format in