show-point-mode.el 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ;;; show-point-mode.el --- show point position in status bar
  2. ;; Copyright (C) 2007, 2010, 2012 Toby Cubitt
  3. ;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
  4. ;; Version: 0.2.1
  5. ;; Keywords: point, mode line
  6. ;; URL: http://www.dr-qubit.org/emacs.php
  7. ;; This file is NOT part of Emacs.
  8. ;;
  9. ;; This file is free software: you can redistribute it and/or modify it under
  10. ;; the terms of the GNU General Public License as published by the Free
  11. ;; Software Foundation, either version 3 of the License, or (at your option)
  12. ;; any later version.
  13. ;;
  14. ;; This program is distributed in the hope that it will be useful, but WITHOUT
  15. ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  17. ;; more details.
  18. ;;
  19. ;; You should have received a copy of the GNU General Public License along
  20. ;; with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  21. ;;; Commentary:
  22. ;;
  23. ;; A simple minor-mode to display the point in the status bar.
  24. ;;; Code:
  25. (provide 'show-point-mode)
  26. ;; add point display to mode-line construct
  27. (let ((linenum-format (assq 'line-number-mode mode-line-position)))
  28. (setq mode-line-position
  29. (assq-delete-all 'line-number-mode mode-line-position))
  30. (setq mode-line-position
  31. (append mode-line-position
  32. `((show-point-mode
  33. (line-number-mode
  34. ((column-number-mode
  35. (20 (" (%l,%c)" (:eval (format "(%d)" (point)))))
  36. (15 (" L%l" (:eval (format "(%d)" (point)))))))
  37. ((column-number-mode
  38. (15 (" C%c" (:eval (format "(%d)" (point)))))
  39. (10 (:eval (format "(%d") (point))))))
  40. ,linenum-format)))))
  41. (define-minor-mode show-point-mode
  42. "Toggle show-point mode.
  43. With no argument, this command toggles the mode.
  44. A non-null prefix argument turns the mode on.
  45. A null prefix argument turns it off.
  46. When enabled, the value of `point' is displayed in the
  47. mode-line (after the line and column numbers, if those are being
  48. displayed too).")
  49. ;;; show-point-mode.el ends here