Fix some more docstring etc. quoting problems
[emacs.git] / lisp / mb-depth.el
Commit [+]AuthorDateLineData
67832de1
KS
Kim F. Storm2007-06-15 14:36:17 +00001;;; mb-depth.el --- Indicate minibuffer-depth in prompt
2;;
7e09ef09 Paul Eggert2015-01-01 14:26:41 -08003;; Copyright (C) 2006-2015 Free Software Foundation, Inc.
67832de1
KS
Kim F. Storm2007-06-15 14:36:17 +00004;;
5;; Author: Miles Bader <miles@gnu.org>
6;; Keywords: convenience
7
8;; This file is part of GNU Emacs.
9
eb3fa2cf Glenn Morris2008-05-06 08:06:51 +000010;; GNU Emacs is free software: you can redistribute it and/or modify
67832de1 Kim F. Storm2007-06-15 14:36:17 +000011;; it under the terms of the GNU General Public License as published by
eb3fa2cf
GM
Glenn Morris2008-05-06 08:06:51 +000012;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
67832de1
KS
Kim F. Storm2007-06-15 14:36:17 +000014
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
eb3fa2cf Glenn Morris2008-05-06 08:06:51 +000021;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
67832de1
KS
Kim F. Storm2007-06-15 14:36:17 +000022
23;;; Commentary:
24;;
e94d0645 Juri Linkov2008-07-31 17:23:45 +000025;; Defines the minor mode `minibuffer-depth-indicate-mode'.
67832de1
KS
Kim F. Storm2007-06-15 14:36:17 +000026;;
27;; When active, any recursive use of the minibuffer will show
28;; the recursion depth in the minibuffer prompt. This is only
29;; useful if `enable-recursive-minibuffers' is non-nil.
30
31;;; Code:
32
e94d0645 Juri Linkov2008-07-31 17:23:45 +000033(defvar minibuffer-depth-indicator-function nil
3d0910ae
JB
Juanma Barranquero2007-10-08 14:48:39 +000034 "If non-nil, function to set up the minibuffer depth indicator.
35It is called with one argument, the minibuffer depth,
36and must return a string.")
37
67832de1
KS
Kim F. Storm2007-06-15 14:36:17 +000038;; An overlay covering the prompt. This is a buffer-local variable in
39;; each affected minibuffer.
40;;
e94d0645
JL
Juri Linkov2008-07-31 17:23:45 +000041(defvar minibuffer-depth-overlay)
42(make-variable-buffer-local 'minibuffer-depth-overlay)
67832de1
KS
Kim F. Storm2007-06-15 14:36:17 +000043
44;; This function goes on minibuffer-setup-hook
e94d0645
JL
Juri Linkov2008-07-31 17:23:45 +000045(defun minibuffer-depth-setup ()
46 "Set up a minibuffer for `minibuffer-depth-indicate-mode'.
67832de1
KS
Kim F. Storm2007-06-15 14:36:17 +000047The prompt should already have been inserted."
48 (when (> (minibuffer-depth) 1)
e94d0645
JL
Juri Linkov2008-07-31 17:23:45 +000049 (setq minibuffer-depth-overlay (make-overlay (point-min) (1+ (point-min))))
50 (overlay-put minibuffer-depth-overlay 'before-string
51 (if minibuffer-depth-indicator-function
52 (funcall minibuffer-depth-indicator-function (minibuffer-depth))
3d0910ae Juanma Barranquero2007-10-08 14:48:39 +000053 (propertize (format "[%d]" (minibuffer-depth)) 'face 'highlight)))
e94d0645 Juri Linkov2008-07-31 17:23:45 +000054 (overlay-put minibuffer-depth-overlay 'evaporate t)))
67832de1
KS
Kim F. Storm2007-06-15 14:36:17 +000055
56;;;###autoload
e94d0645
JL
Juri Linkov2008-07-31 17:23:45 +000057(define-minor-mode minibuffer-depth-indicate-mode
58 "Toggle Minibuffer Depth Indication mode.
06e21633
CY
Chong Yidong2011-10-19 08:54:24 -040059With a prefix argument ARG, enable Minibuffer Depth Indication
60mode if ARG is positive, and disable it otherwise. If called
61from Lisp, enable the mode if ARG is omitted or nil.
67832de1 Kim F. Storm2007-06-15 14:36:17 +000062
06e21633
CY
Chong Yidong2011-10-19 08:54:24 -040063Minibuffer Depth Indication mode is a global minor mode. When
64enabled, any recursive use of the minibuffer will show the
65recursion depth in the minibuffer prompt. This is only useful if
66`enable-recursive-minibuffers' is non-nil."
67832de1
KS
Kim F. Storm2007-06-15 14:36:17 +000067 :global t
68 :group 'minibuffer
e94d0645 Juri Linkov2008-07-31 17:23:45 +000069 (if minibuffer-depth-indicate-mode
67832de1 Kim F. Storm2007-06-15 14:36:17 +000070 ;; Enable the mode
e94d0645 Juri Linkov2008-07-31 17:23:45 +000071 (add-hook 'minibuffer-setup-hook 'minibuffer-depth-setup)
67832de1 Kim F. Storm2007-06-15 14:36:17 +000072 ;; Disable the mode
e94d0645 Juri Linkov2008-07-31 17:23:45 +000073 (remove-hook 'minibuffer-setup-hook 'minibuffer-depth-setup)))
67832de1
KS
Kim F. Storm2007-06-15 14:36:17 +000074
75(provide 'mb-depth)
76
77;;; mb-depth.el ends here