X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/245be23c669af9fa2a241531a74522b5cccc884c..ad235a8b88e353d6e51dafc62d020d8ff647857f:/lisp/linum.el diff --git a/lisp/linum.el b/lisp/linum.el index 81b48e9906..d9d7e5ad12 100644 --- a/lisp/linum.el +++ b/lisp/linum.el @@ -1,10 +1,11 @@ -;;; linum.el --- display line numbers in the left margin +;;; linum.el --- display line numbers in the left margin -*- lexical-binding: t -*- -;; Copyright (C) 2008, 2009 Free Software Foundation, Inc. +;; Copyright (C) 2008-2013 Free Software Foundation, Inc. ;; Author: Markus Triska ;; Maintainer: FSF ;; Keywords: convenience +;; Version: 0.9x ;; This file is part of GNU Emacs. @@ -43,7 +44,6 @@ "Show line numbers in the left margin." :group 'convenience) -;;;###autoload (defcustom linum-format 'dynamic "Format used to display line numbers. Either a format string like \"%7d\", `dynamic' to adapt the width @@ -51,7 +51,9 @@ as needed, or a function that is called with a line number as its argument and should evaluate to a string to be shown on that line. See also `linum-before-numbering-hook'." :group 'linum - :type 'sexp) + :type '(choice (string :tag "Format string") + (const :tag "Dynamic width" dynamic) + (function :tag "Function"))) (defface linum '((t :inherit (shadow default))) @@ -72,7 +74,12 @@ and you have to scroll or press \\[recenter-top-bottom] to update the numbers." ;;;###autoload (define-minor-mode linum-mode - "Toggle display of line numbers in the left margin." + "Toggle display of line numbers in the left margin (Linum mode). +With a prefix argument ARG, enable Linum mode if ARG is positive, +and disable it otherwise. If called from Lisp, enable the mode +if ARG is omitted or nil. + +Linum mode is a buffer-local minor mode." :lighter "" ; for desktop.el (if linum-mode (progn @@ -166,18 +173,21 @@ and you have to scroll or press \\[recenter-top-bottom] to update the numbers." (overlay-put ov 'before-string (propertize " " 'display `((margin left-margin) ,str))) (overlay-put ov 'linum-str str)))) - (forward-line) + ;; Text may contain those nasty intangible properties, but that + ;; shouldn't prevent us from counting those lines. + (let ((inhibit-point-motion-hooks t)) + (forward-line)) (setq line (1+ line))) (set-window-margins win width (cdr (window-margins win))))) -(defun linum-after-change (beg end len) +(defun linum-after-change (beg end _len) ;; update overlays on deletions, and after newlines are inserted (when (or (= beg end) (= end (point-max)) (string-match-p "\n" (buffer-substring-no-properties beg end))) (linum-update-current))) -(defun linum-after-scroll (win start) +(defun linum-after-scroll (win _start) (linum-update (window-buffer win))) ;; (defun linum-after-size (frame) @@ -198,5 +208,4 @@ and you have to scroll or press \\[recenter-top-bottom] to update the numbers." (provide 'linum) -;; arch-tag: dea45631-ed3c-4867-8b49-1c41c80aec6a ;;; linum.el ends here