X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/a113b3ca322fd73d97d0d9d69c9f48dc13fb326a..f019fb210628549b661bf7ebaa40e136df205af4:/lisp/ruler-mode.el diff --git a/lisp/ruler-mode.el b/lisp/ruler-mode.el index 10bf7ca873..fc62bf6b63 100644 --- a/lisp/ruler-mode.el +++ b/lisp/ruler-mode.el @@ -1,7 +1,6 @@ ;;; ruler-mode.el --- display a ruler in the header line -;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, -;; 2007, 2008 Free Software Foundation, Inc. +;; Copyright (C) 2001-2011 Free Software Foundation, Inc. ;; Author: David Ponce ;; Maintainer: David Ponce @@ -11,20 +10,18 @@ ;; This file is part of GNU Emacs. -;; This program is free software; you can redistribute it and/or -;; modify it under the terms of the GNU General Public License as -;; published by the Free Software Foundation; either version 3, or (at -;; your option) any later version. +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. -;; This program is distributed in the hope that it will be useful, but -;; WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -;; General Public License for more details. +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with this program; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. +;; along with GNU Emacs. If not, see . ;;; Commentary: @@ -121,7 +118,7 @@ :group 'convenience) (defcustom ruler-mode-show-tab-stops nil - "*If non-nil the ruler shows tab stop positions. + "If non-nil the ruler shows tab stop positions. Also allowing to visually change `tab-stop-list' setting using and on the ruler to respectively add or remove a tab stop. \\[ruler-mode-toggle-show-tab-stops] or @@ -143,7 +140,7 @@ or remove a tab stop. \\[ruler-mode-toggle-show-tab-stops] or (defcustom ruler-mode-fill-column-char (if (char-displayable-p ?¶) ?\¶ ?\|) - "*Character used at the `fill-column' location." + "Character used at the `fill-column' location." :group 'ruler-mode :type '(choice (character :tag "Character") @@ -151,7 +148,7 @@ or remove a tab stop. \\[ruler-mode-toggle-show-tab-stops] or :validate ruler-mode-character-validate))) (defcustom ruler-mode-comment-column-char ?\# - "*Character used at the `comment-column' location." + "Character used at the `comment-column' location." :group 'ruler-mode :type '(choice (character :tag "Character") @@ -159,7 +156,7 @@ or remove a tab stop. \\[ruler-mode-toggle-show-tab-stops] or :validate ruler-mode-character-validate))) (defcustom ruler-mode-goal-column-char ?G - "*Character used at the `goal-column' location." + "Character used at the `goal-column' location." :group 'ruler-mode :type '(choice (character :tag "Character") @@ -169,7 +166,7 @@ or remove a tab stop. \\[ruler-mode-toggle-show-tab-stops] or (defcustom ruler-mode-current-column-char (if (char-displayable-p ?¦) ?\¦ ?\@) - "*Character used at the `current-column' location." + "Character used at the `current-column' location." :group 'ruler-mode :type '(choice (character :tag "Character") @@ -177,7 +174,7 @@ or remove a tab stop. \\[ruler-mode-toggle-show-tab-stops] or :validate ruler-mode-character-validate))) (defcustom ruler-mode-tab-stop-char ?\T - "*Character used at `tab-stop-list' locations." + "Character used at `tab-stop-list' locations." :group 'ruler-mode :type '(choice (character :tag "Character") @@ -185,7 +182,7 @@ or remove a tab stop. \\[ruler-mode-toggle-show-tab-stops] or :validate ruler-mode-character-validate))) (defcustom ruler-mode-basic-graduation-char ?\. - "*Character used for basic graduations." + "Character used for basic graduations." :group 'ruler-mode :type '(choice (character :tag "Character") @@ -193,7 +190,7 @@ or remove a tab stop. \\[ruler-mode-toggle-show-tab-stops] or :validate ruler-mode-character-validate))) (defcustom ruler-mode-inter-graduation-char ?\! - "*Character used for intermediate graduations." + "Character used for intermediate graduations." :group 'ruler-mode :type '(choice (character :tag "Character") @@ -201,7 +198,7 @@ or remove a tab stop. \\[ruler-mode-toggle-show-tab-stops] or :validate ruler-mode-character-validate))) (defcustom ruler-mode-set-goal-column-ding-flag t - "*Non-nil means do `ding' when `goal-column' is set." + "Non-nil means do `ding' when `goal-column' is set." :group 'ruler-mode :type 'boolean) @@ -551,22 +548,37 @@ This variable is expected to be made buffer-local by modes.") "`header-line-format' used in ruler mode. Call `ruler-mode-ruler-function' to compute the ruler value.") +;;;###autoload +(defvar ruler-mode nil + "Non-nil if Ruler mode is enabled. +Use the command `ruler-mode' to change this variable.") +(make-variable-buffer-local 'ruler-mode) + +(defun ruler--save-header-line-format () + "Install the header line format for Ruler mode. +Unless Ruler mode is already enabled, save the old header line +format first." + (when (and (not ruler-mode) + (local-variable-p 'header-line-format) + (not (local-variable-p 'ruler-mode-header-line-format-old))) + (set (make-local-variable 'ruler-mode-header-line-format-old) + header-line-format)) + (setq header-line-format ruler-mode-header-line-format)) + ;;;###autoload (define-minor-mode ruler-mode - "Display a ruler in the header line if ARG > 0." + "Toggle Ruler mode. +In Ruler mode, Emacs displays a ruler in the header line." nil nil ruler-mode-map :group 'ruler-mode + :variable (ruler-mode + . (lambda (enable) + (when enable + (ruler--save-header-line-format)) + (setq ruler-mode enable))) (if ruler-mode - (progn - ;; When `ruler-mode' is on save previous header line format - ;; and install the ruler header line format. - (when (and (local-variable-p 'header-line-format) - (not (local-variable-p 'ruler-mode-header-line-format-old))) - (set (make-local-variable 'ruler-mode-header-line-format-old) - header-line-format)) - (setq header-line-format ruler-mode-header-line-format) - (add-hook 'post-command-hook 'force-mode-line-update nil t)) + (add-hook 'post-command-hook 'force-mode-line-update nil t) ;; When `ruler-mode' is off restore previous header line format if ;; the current one is the ruler header line format. (when (eq header-line-format ruler-mode-header-line-format) @@ -666,7 +678,7 @@ Optional argument PROPS specifies other text properties to apply." ;; Create an "clean" ruler. (ruler (propertize - (string-to-multibyte + (string-to-multibyte (make-string w ruler-mode-basic-graduation-char)) 'face 'ruler-mode-default 'local-map ruler-mode-map @@ -763,5 +775,4 @@ Optional argument PROPS specifies other text properties to apply." ;; coding: iso-latin-1 ;; End: -;; arch-tag: b2f24546-5605-44c4-b67b-c9a4eeba3ee8 ;;; ruler-mode.el ends here