help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How properly utilize the minibuffer and inactive minibuffer startup


From: Michael Heerdegen
Subject: Re: How properly utilize the minibuffer and inactive minibuffer startup hooks?
Date: Thu, 10 Jul 2014 00:08:04 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.92 (gnu/linux)

Hi Grant,


No, it's not your fault.

As you presumably already found out, the first time you enter a
minibuffer and minibuffer-setup-hook is run, the minibuffer is in
fundamental-mode.  The second time, however, it is in
minibuffer-inactive-mode.

`smartparens-mode` silently fails when the current major mode is in
`sp-ignore-modes-list`.  The default-value of `sp-ignore-modes-list` is
'(minibuffer-inactive-mode) -- but I don't know why the smartparens
developer decided to do so.

So, you should get it work when you remove `minibuffer-inactive-mode`
from `sp-ignore-modes-list` - at your own risk.

Adding to minibuffer-setup-hook is enough, btw, pushing your setup
function to minibuffer-inactive-mode-hook as well is not necessary.


BTW, another, maybe a bit saner, approach is to write your own
implementation of eval-expression.  This is what I use, for example:

,----------------------------------------------------------------------
| (progn
|   
|   (defvar my-read-expression-map
|     (let ((map (make-sparse-keymap)))
|       (set-keymap-parent map read-expression-map)
|       (define-key map [(control ?g)] #'minibuffer-keyboard-quit)
|       (define-key map [up]   nil)
|       (define-key map [down] nil)
|       map))
| 
|   (defun my-read--expression (prompt &optional initial-contents)
|     (let ((minibuffer-completing-symbol t))
|       (minibuffer-with-setup-hook
|           (lambda ()
|             (emacs-lisp-mode)
|             (use-local-map my-read-expression-map)
|             (setq font-lock-mode t)
|             (funcall font-lock-function 1))
|         (read-from-minibuffer prompt initial-contents
|                               my-read-expression-map nil
|                               'read-expression-history))))
| 
|   (defun my-eval-expression (expression &optional arg)
|     (interactive (list (read (my-read--expression ""))
|                        current-prefix-arg))
|     (if arg
|         (insert (pp-to-string (eval expression lexical-binding)))
|       (pp-display-expression (eval expression lexical-binding)
|                              "*Pp Eval Output*"))))
`----------------------------------------------------------------------

smartparens-mode is enabled automatically via emacs-lisp-mode.

I also want to make the R command in the debugger behave the same
way:

,----------------------------------------------------------------------
| (advice-add
|  'debugger-record-expression :around
|  (lambda (f exp) (interactive
|              (list (read (my-read--expression "Record Eval: "))))
|    (funcall f exp))
|  '((name . use-my-read--expression)))
`----------------------------------------------------------------------


HTH,

Michael.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]