]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/eldoc-eval/eldoc-eval.el
* packages/auctex/tex-jp.el: Fix up copyright line.
[gnu-emacs-elpa] / packages / eldoc-eval / eldoc-eval.el
index 777bb9b816851c375567bae2359f7b51ce0a877d..b6c4f59b4325f37c5c16800e1b5be94719e6c511 100644 (file)
@@ -1,8 +1,9 @@
-;;; eldoc-eval.el -- Show eldoc when using M-:
+;;; eldoc-eval.el --- Enable eldoc support when minibuffer is in use.
 
-;; Copyright (C) 2011 Free Software Foundation, Inc.
+;; Copyright (C) 2011, 2012 Free Software Foundation, Inc.
 
 ;; Author: Thierry Volpiatto <thierry.volpiatto@gmail.com>
+;; Version: 0.1
 
 ;; This file is part of GNU Emacs.
 
 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
+;;
+;; This package enables eldoc support when minibuffer is in use.
+;;
+;; Eldoc info is shown by default in mode-line,
+;; but you can have eldoc info somewhere else by setting
+;; `eldoc-in-minibuffer-show-fn' to another function (e.g `tooltip-show').
+;;
+;; By default with this package `M-:' will use `pp-eval-expression'
+;; instead of `eval-expression'; you can change that by setting
+;; `eval-preferred-function'.
+;;
+;; It also provides a convenient macro to enable eldoc support
+;; in your own functions using minibuffer or in your defadvices,
+;; that is `with-eldoc-in-minibuffer'.
+;;
+;; Users of own minibuffer frame will have to set
+;; `eldoc-in-minibuffer-own-frame-p' to non-nil.
+;;
+;; You can turn off eldoc support in minibuffer any time
+;; by setting `eldoc-in-minibuffer' to nil.
 
 ;;; Code:
 (require 'eldoc)
@@ -45,19 +66,19 @@ Should take one arg: the string to display"
   :group 'eldoc
   :type 'number)
 
-(defcustom eval-prefered-function 'pp-eval-expression
-  "Prefered function to use with `M-:'."
+(defcustom eval-preferred-function 'pp-eval-expression
+  "Preferred function to use with `M-:'."
   :group 'lisp
   :type 'function)
 
 (defcustom  eldoc-in-minibuffer-own-frame-p nil
-  "Whether minibuffer have own frame or not."
+  "Whether minibuffer has its own frame or not."
   :group 'lisp
   :type 'boolean)
 
 ;; Internal.
 (defvar eldoc-active-minibuffers-list nil
-  "Store actives minibuffers with eldoc enabled.")
+  "List of active minibuffers with eldoc enabled.")
 (defvar eldoc-mode-line-rolling-flag nil)
 
 (defun eldoc-store-minibuffer ()
@@ -68,7 +89,7 @@ See `with-eldoc-in-minibuffer'."
     (push (buffer-name) eldoc-active-minibuffers-list)))
 
 (defmacro with-eldoc-in-minibuffer (&rest body)
-  "Enable eldoc support for minibuffer input that run in BODY."
+  "Enable eldoc support for minibuffer input that runs in BODY."
   (declare (indent 0) (debug t))
   `(let ((timer (and eldoc-in-minibuffer
                      (run-with-idle-timer
@@ -81,21 +102,21 @@ See `with-eldoc-in-minibuffer'."
              'eldoc-store-minibuffer
            ,@body)
        (and timer (cancel-timer timer))
-       ;; Each time a minibuffer exit or abort
-       ;; his buffer is removed from stack,
+       ;; Each time a minibuffer exits or aborts
+       ;; its buffer is removed from stack,
        ;; assuming we can only exit the active minibuffer
        ;; on top of stack.
        (setq eldoc-active-minibuffers-list
              (cdr eldoc-active-minibuffers-list)))))
 
 (defun eldoc-current-buffer ()
-  "The `current-buffer' before activating minibuffer."
+  "Return the current buffer prior to activating the minibuffer."
   (with-selected-frame (last-nonminibuffer-frame)
     (window-buffer
      (cond (eldoc-in-minibuffer-own-frame-p
             (selected-window))
            ((fboundp 'window-in-direction)
-            (window-in-direction 
+            (window-in-direction
              'above (minibuffer-window)))
            (t (minibuffer-selected-window))))))
 
@@ -153,7 +174,7 @@ See `with-eldoc-in-minibuffer'."
   "Eval expression with eldoc support in mode-line."
   (interactive)
   (with-eldoc-in-minibuffer
-    (call-interactively eval-prefered-function)))
+    (call-interactively eval-preferred-function)))
 
 ;; Bind it to `M-:'.
 (global-set-key [remap eval-expression] 'eval-expression-with-eldoc)