* Re: How properly utilize the minibuffer and inactive minibuffer startup hooks? [not found] <mailman.5105.1404869933.1147.help-gnu-emacs@gnu.org> @ 2014-07-10 12:46 ` jduthen 2014-07-10 15:08 ` Grant Rettke 0 siblings, 1 reply; 6+ messages in thread From: jduthen @ 2014-07-10 12:46 UTC (permalink / raw) To: help-gnu-emacs Le mardi 8 juillet 2014 22:07:59 UTC+2, Grant Rettke wrote : > > 1 My goal > ═════════ > > My goal is to enable [smartparens] in the minibuffer > but only when calling `eval-expression'. If, by any chance, your goal is a subgoal of enabling smartparens when evaluating some lisp expressions, I would recommand to use: M-x ielm RET Usually, when I have to type M-: more than once or if the expression is complexe enough to require paren matching, I tend to use ielm. Maybe that might help... )jack( ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How properly utilize the minibuffer and inactive minibuffer startup hooks? 2014-07-10 12:46 ` How properly utilize the minibuffer and inactive minibuffer startup hooks? jduthen @ 2014-07-10 15:08 ` Grant Rettke 2014-07-10 16:09 ` Drew Adams 0 siblings, 1 reply; 6+ messages in thread From: Grant Rettke @ 2014-07-10 15:08 UTC (permalink / raw) To: jduthen; +Cc: Emacs Help Good point as I'd been using eval-expression just like an IELM. Grant Rettke | ACM, ASA, FSF, IEEE, SIAM gcr@wisdomandwonder.com | http://www.wisdomandwonder.com/ “Wisdom begins in wonder.” --Socrates ((λ (x) (x x)) (λ (x) (x x))) “Life has become immeasurably better since I have been forced to stop taking it seriously.” --Thompson On Thu, Jul 10, 2014 at 7:46 AM, <jduthen@gmail.com> wrote: > Le mardi 8 juillet 2014 22:07:59 UTC+2, Grant Rettke wrote : >> >> 1 My goal >> ═════════ >> >> My goal is to enable [smartparens] in the minibuffer >> but only when calling `eval-expression'. > > If, by any chance, your goal is a subgoal of enabling smartparens > when evaluating some lisp expressions, I would recommand to use: > M-x ielm RET > > Usually, when I have to type M-: more than once > or if the expression is complexe enough to require paren matching, > I tend to use ielm. > > Maybe that might help... > > )jack( ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: How properly utilize the minibuffer and inactive minibuffer startup hooks? 2014-07-10 15:08 ` Grant Rettke @ 2014-07-10 16:09 ` Drew Adams 0 siblings, 0 replies; 6+ messages in thread From: Drew Adams @ 2014-07-10 16:09 UTC (permalink / raw) To: Grant Rettke, jduthen; +Cc: Emacs Help > >> 1 My goal > >> ═════════ > >> > >> My goal is to enable [smartparens] in the minibuffer > >> but only when calling `eval-expression'. > > > > If, by any chance, your goal is a subgoal of enabling smartparens > > when evaluating some lisp expressions, I would recommand to use: > > M-x ielm RET > > > > Usually, when I have to type M-: more than once > > or if the expression is complexe enough to require paren matching, > > I tend to use ielm. > > Good point as I'd been using eval-expression just like an IELM. FWIW - 1. You _can_ reasonably use the minibuffer for evaluating complex sexps. Michael H's email answers your question in this regard. And I would add the suggestion to change `M-:' from `eval-expression' to `pp-eval-expression'. It is generally more useful to examine a pretty-printed result (this should be the default behavior in Emacs, IMO, but it is not). 2. Another alternative to using ielm is to just use *scratch* or an Emacs-Lisp buffer to evaluate sexps. 3. Personally, I have `M-:' in the minibuffer bound to `icicle-pp-eval-expression-in-minibuffer', which just calls `icicle-pp-eval-expression from a recursive minibuffer. And the latter command is like `pp-eval-expression' but it respects user options `icicle-pp-eval-expression-print-length', `icicle-pp-eval-expression-print-level', and `eval-expression-debug-on-error'. (If you don't use Icicles then you can get similar behavior wrt pretty-printing from library pp+.el.) And personally I don't bother with `smartparens-mode' (but see Michael H's solution for that). I use only `show-paren-mode' (and there is no problem with that in the minibuffer). ^ permalink raw reply [flat|nested] 6+ messages in thread
* How properly utilize the minibuffer and inactive minibuffer startup hooks? @ 2014-07-08 20:07 Grant Rettke 2014-07-09 22:08 ` Michael Heerdegen 0 siblings, 1 reply; 6+ messages in thread From: Grant Rettke @ 2014-07-08 20:07 UTC (permalink / raw) To: Emacs Help Good morning, 1 My goal ═════════ My goal is to enable [smartparens] in the minibuffer but only when calling `eval-expression'. That includes the inactive minibuffer. My attempt to do so looks like this: ╭──── │ (defun gcr/smartparens-if-eval-expr () │ "Enable Smartparens in the mini-buffer but only when eval'ing expressions" │ (if (eq this-command 'eval-expression) │ (turn-on-smartparens-strict-mode))) │ │ (defun gcr/minibuffer-setup-hook () │ "Personal setup." │ (local-set-key "ESC y" 'gcr/paste-from-x-clipboard) │ (gcr/smartparens-if-eval-expr)) │ │ (add-hook 'minibuffer-setup-hook 'gcr/minibuffer-setup-hook) │ │ (add-hook 'minibuffer-inactive-mode-hook 'gcr/minibuffer-setup-hook) ╰──── What I expected is that `smartparens' would be enabled every time I enter the minibuffer. The problem I am facing is that it is not. [smartparens] https://github.com/Fuco1/smartparens 2 Issue and questions ═════════════════════ Instead: • It is only turned on inside of the minibuffer on the first call to `eval-expression' • Every call after that to `eval-expression' does not result in `smartparens' being enabled "Being enabled" means that: • After starting Emacs • After typing `M-:', entering a open round bracket, and I will see the right balanced bracket inserted, too. • While in that minibuffer, doing a `C-h m' shows the list of modes and Smartparen is in there. It looks like this: • `Show-Smartparens-Global Size-Indication Smartparens Smartparens-Strict' Following those steps, within the same Emacs session, the 2nd time that I try to perform those steps it is no longer true in that: 1. Smartparens is not turned on. One thing that I did check for is that I am in the correct mode and command added in the hook this: ╭──── │ (print (format "%s %s" mode-name this-command)) ╰──── And got what I expected 3 times: ╭──── │ InactiveMinibuffer eval-expression ╰──── Clearly, *I* am doing something wrong, not the modeline or Smartparens. I am looking for thoughts on what I am doing wrong, and wondering what I may do different to investigate and discover the nature my error since: • Smartparens works fine • Modeline works fine • What am I doing wrong? 3 My environment ════════════════ My environment: ╭──── │ (print (format "%s" emacs-version)) ╰──── ╭──── │ =24.3.1 │ =" │ \"24.3.1\" │ " ╰──── ╭──── │ uname -a ╰──── ╭──── │ Darwin orion 13.2.0 Darwin Kernel Version 13.2.0: Thu Apr 17 23:03:13 PDT 2014; root:xnu-2422.100.13~1/RELEASE_X86_64 x86_64 ╰──── Kind regards, gcr ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How properly utilize the minibuffer and inactive minibuffer startup hooks? 2014-07-08 20:07 Grant Rettke @ 2014-07-09 22:08 ` Michael Heerdegen 2014-07-11 0:51 ` Grant Rettke 0 siblings, 1 reply; 6+ messages in thread From: Michael Heerdegen @ 2014-07-09 22:08 UTC (permalink / raw) To: help-gnu-emacs 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. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How properly utilize the minibuffer and inactive minibuffer startup hooks? 2014-07-09 22:08 ` Michael Heerdegen @ 2014-07-11 0:51 ` Grant Rettke 0 siblings, 0 replies; 6+ messages in thread From: Grant Rettke @ 2014-07-11 0:51 UTC (permalink / raw) To: Michael Heerdegen; +Cc: Emacs Help Thank you everyone. Michael, that R advice looks like it is for Emacs 24.4, and I look forward to using it. Grant Rettke | ACM, ASA, FSF, IEEE, SIAM gcr@wisdomandwonder.com | http://www.wisdomandwonder.com/ “Wisdom begins in wonder.” --Socrates ((λ (x) (x x)) (λ (x) (x x))) “Life has become immeasurably better since I have been forced to stop taking it seriously.” --Thompson On Wed, Jul 9, 2014 at 5:08 PM, Michael Heerdegen <michael_heerdegen@web.de> wrote: > 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. > > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-07-11 0:51 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <mailman.5105.1404869933.1147.help-gnu-emacs@gnu.org> 2014-07-10 12:46 ` How properly utilize the minibuffer and inactive minibuffer startup hooks? jduthen 2014-07-10 15:08 ` Grant Rettke 2014-07-10 16:09 ` Drew Adams 2014-07-08 20:07 Grant Rettke 2014-07-09 22:08 ` Michael Heerdegen 2014-07-11 0:51 ` Grant Rettke
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).