From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: How properly utilize the minibuffer and inactive minibuffer startup hooks? Date: Thu, 10 Jul 2014 00:08:04 +0200 Message-ID: <87pphexk1n.fsf@web.de> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1404946652 15590 80.91.229.3 (9 Jul 2014 22:57:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 9 Jul 2014 22:57:32 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 10 00:57:25 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X50nl-0006er-B2 for geh-help-gnu-emacs@m.gmane.org; Thu, 10 Jul 2014 00:57:25 +0200 Original-Received: from localhost ([::1]:34135 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X508y-0003t2-HM for geh-help-gnu-emacs@m.gmane.org; Wed, 09 Jul 2014 18:15:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X502N-0000LG-L1 for help-gnu-emacs@gnu.org; Wed, 09 Jul 2014 18:08:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X502G-0001DK-2f for help-gnu-emacs@gnu.org; Wed, 09 Jul 2014 18:08:27 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:33177) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X502F-0001DD-Rg for help-gnu-emacs@gnu.org; Wed, 09 Jul 2014 18:08:19 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1X502D-0001od-6O for help-gnu-emacs@gnu.org; Thu, 10 Jul 2014 00:08:17 +0200 Original-Received: from dslb-094-217-127-201.pools.arcor-ip.net ([94.217.127.201]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 10 Jul 2014 00:08:17 +0200 Original-Received: from michael_heerdegen by dslb-094-217-127-201.pools.arcor-ip.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 10 Jul 2014 00:08:17 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 75 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: dslb-094-217-127-201.pools.arcor-ip.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.92 (gnu/linux) Cancel-Lock: sha1:Ab9DpPtMaflxHZlgQsz81XHmtEI= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:98606 Archived-At: 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.