ergoemacs-org-meta(direction) and ergoemacs-(forward|backward)-… in conflict

34 views
Skip to first unread message

tinakell...@gmail.com

unread,
May 4, 2018, 10:19:15 PM5/4/18
to ErgoEmacs
This is an annoying problem I’ve had for a while. When I load an org-mode buffer, sometimes Alt+left will be “ergoemacs-org-metaleft” and sometimes it will be “ergoemacs-backward-open-bracket”, and so on with the other “ergoemacs-org-meta”(direction) bindings. (This happens no matter the state of the relevant Customize options.) It doesn’t seem to happen when I use the minimal ErgoEmacs configuration as described in https://ergoemacs.github.io/bug-report.html, so I guess it has something to do with my configuration, but I don’t know where I’d even begin to look for the problem there. I’d be happy to know anything that might help.

(If anyone actually wants to trudge through my settings, they’re attached—it’s still a hodgepodge of my own settings and ergoemacs-config.el, though now I’ve tried to start moving my settings into an org file with org-dotemacs… this problem started happening long before that, though.)
init.el
settings.org

tinakell...@gmail.com

unread,
May 18, 2018, 2:50:41 PM5/18/18
to ErgoEmacs
I’ve been working on streamlining and organizing my settings to try and figure out what's causing this bug, without much luck. I can’t really make heads or tails of the problem—if I type “F1 k Alt+up”, for instance, I’ll get the help for “ergoemacs-backward-block”, which will tell me the key is defined in “ergoemacs--original-local-map”; that map (as shown via “F1 v ergoemacs-original-local-map”) doesn’t appear to by any different whether or not I’m on a session where the org-meta direction keys have randomly started working.

I’m not a programmer by trade, but I’d be really happy to help fix this bug, as it’s currently my #1 Emacs problem. Let me know if there is any information to provide, if there are any functions I should look into, and so on. I don’t know too much about the ErgoEmacs internals but I’d be happy to learn about that, too (so we can identify where this problem may be taking place).

Thanks!

—Tina

Matthew Fidler

unread,
May 18, 2018, 11:46:16 PM5/18/18
to ergo...@googlegroups.com
Hi Tina,

I am also not a professional programmer by trade

First; Is there anything you are doing to customize org-mode?  If so, what.

As far as ergoemacs-mode internals, in theroy this is what happens:

1.  You define an ergoemacs-mode theme
2.  Ergoemcs mode maps through every active map that is at the current cursor point and looks up what the emacs key is.  (I think C-n is next line for instance)
3. Ergoemacs makes/loads a new keymap with this key mapped to the corresponding ergoemacs-mode key.

Sometimes this is done through a "command loop" which is where ergoemacs-mode takes over emacs entirely and waits for all input to translate to the next key.  Sometimes this is done when a key isn't found.  

I must say, I haven't touched the code much for a long time, though I still use it every day.  I am resource constrained, I always think someday I will revisit ergoemacs-mode and smooth out some of its edges.

Hopefully this is helpful for you.

Matt

--
You received this message because you are subscribed to the Google Groups "ErgoEmacs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ergoemacs+...@googlegroups.com.
To post to this group, send email to ergo...@googlegroups.com.
Visit this group at https://groups.google.com/group/ergoemacs.
For more options, visit https://groups.google.com/d/optout.

tinakell...@gmail.com

unread,
May 23, 2020, 9:35:39 PM5/23/20
to ErgoEmacs
I’m actually not sure how I fixed this problem… I remembered this post because I’ve been frustrated by a similar problem involving Alt+[direction] bindings.

So, for some time I’ve been trying to bind Alt+[direction] as lispy-move-[direction] in lisp-mode-shared-map (which is used as a parent keymap to all the various Lisp modes’ major maps). These bindings, once I’ve set them, are shown in the values of emacs-lisp-mode-map, common-lisp-mode-map, etc. Trouble is, no matter what, if I press, say, Alt+left in, say, emacs-lisp-mode, it will always activate ergoemacs-backward-open-bracket. According to define-key, this is because of a binding in ergoemacs--original-local-map. If I look at the value of ergoemacs--original-local-map in a Lisp buffer, it will show my Lispy Alt+[direction] bindings, and then the ErgoEmacs Alt+[direction] bindings later in the list (and apparently, they take precedence).

What really confuses me is that org-mode also binds Alt+[direction], for each direction, and ergoemacs-mode respects that perfectly well. Pressing Alt+left in an Org buffer will invoke org-metaleft every time. If I look at the value of ergoemacs--original-local-map, the Org Alt+[direction] bindings are present, and ErgoEmacs Alt+[direction] bindings aren’t. (note that I’m not talking about ergoemacs-org-metaleft and cousins; I mean ergoemacs-backward-open-bracket and such.)

How is it that Lisp buffers have Alt+[direction] so hard-set, and Org buffers don’t? Any idea how I can get my preferred bindings in the Lisp modes? (Just in case, I tried adding the lispy-move-[direction] functions to ergoemacs-functions-that-always-override-ergoemacs-mode; sadly, with no luck.) I’m also kind of curious how ergoemacs--original-local-map works, because it comes up so often when I’m trying to debug ergoemacs-mode but it’s sparsely mentioned in the code. Thank you!

—Tina
To unsubscribe from this group and stop receiving emails from it, send an email to ergo...@googlegroups.com.

tinakell...@gmail.com

unread,
May 24, 2020, 8:36:05 PM5/24/20
to ErgoEmacs
In the meantime, here’s my hacky solution that seems to work: instead of actually changing the bindings, I just advise all the relevant functions to do something different if the current major mode is a Lisp mode.

(defvar tina/lisp-modes (delete-dups
                         (append align-lisp-modes lispy-elisp-modes lispy-clojure-modes)))

(defun tina/lisp-mode-p (&optional mode)
  (apply #'provided-mode-derived-p (or mode major-mode) tina/lisp-modes))

(cl-macrolet ((make-lispy-advice (func direction)
                                 `(define-advice ,func (:before-until (arg) tina-lispy)
                                    (when (tina/lisp-mode-p)
                                      (funcall ',(intern (format "lispy-move-%s" direction)) arg)))))
  (make-lispy-advice ergoemacs-backward-block up)
  (make-lispy-advice ergoemacs-forward-block down)
  (make-lispy-advice ergoemacs-backward-open-bracket left)
  (make-lispy-advice ergoemacs-forward-close-bracket right))
Reply all
Reply to author
Forward
0 new messages