2

Paraphrasing a question I previously asked on SuperUser because, IMO, the answer found there does not resolve the issue.

Question

For the most part I prefer to disable Emacs' fringe. (I customize fringe-mode to 0 a/k/a no-fringes) But I like to have the left fringe active when debugging elisp code (for the little fringe arrow pointing to the active line).

How can I configure Emacs to switch to fringe-mode of (nil . 0) a/k/a left-only when entering edebug and restore the previous fringe-mode when exiting?

Update

Since Emacs 24.3 is the latest stable release as of this writing, I have a preference for solutions that work there. Since Emacs 24.4 is available, in feature-freeze, and actively in use by several users of this site, I'm accepting that answer.

purple_arrows
  • 2,373
  • 10
  • 19
  • 1
    I can confirm that the suggested code works perfectly for me. You might want to verify the behavior on your side with `emacs -q` – Sigma Oct 06 '14 at 16:08
  • Even the `message` code? I've tried `emacs -Q` + eval either one, or both, in the \*scratch\* buffer, call a command I'd previously instrumented with `C-u C-M-x`. I have yet to see any joy. – purple_arrows Oct 06 '14 at 21:22
  • Could you describe what you mean by "works perfectly"? – purple_arrows Oct 06 '14 at 21:30
  • If "***`edebug-mode-hook` is never run***", then clearly you cannot say that the function added to that hook does not work. *Suggestion:* Figure out why it does not run - that's your first step. – Drew Oct 07 '14 at 01:01
  • Sorry to be explicit, but I'm calling B.S. that `edebug-mode-hook` exists in Emacs. I cannot find it documented anywhere, I see no reason to believe that the code in edebug.el creates it, and all suggested code that I write fails to use it the way one would expect. This is all true when I start from `emacs -Q`. *breathe* It may be my ignorance of the internals of edebug. When I go: `emacs -Q`, instrument a command with `C-u C-M-x`, call the command, then go `C-h v edebug-mode-hook RET` I am taken to the (sparse) documentation of the `edebug-eval-mode-hook`. What am I missing? – purple_arrows Oct 07 '14 at 01:14
  • 1
    To be clear: I'm not claiming that the code given above fails to compile, or that the functions in the lambda forms are somehow broken. I'm claiming that the call to `add-hook` creates a hook symbol that never existed before, and I see no reason to expect edebug to ever consult that symbol again. – purple_arrows Oct 07 '14 at 01:18
  • Try loading the edebug library `M-x load-library` before searching for `edebug-mode-hook`. It is a mode hook and does not have to be explicitly defined. – Vamsi Oct 07 '14 at 07:34
  • 1
    *People the discrepancy probably comes from emacs versions.* In **Emacs 24.3**, `edebug-mode` is a standard function, and `edebug-mode-hook` really isn’t used *nor* defined. In **Emacs 24.4**, `edebug-mode` is defined through `define-minor-mode`, so `edebug-mode-hook` is defined *and* used. – Malabarba Oct 07 '14 at 10:22
  • @Malabarba, thank you! And thanks to everybody for helping me debug this. *facepalm* If any participant in this helpful thread would like to write that up as an answer, I'll accept it. I'm not sure how content I am with "upgrade to the dev version of Emacs" but it *is* a valid answer. – purple_arrows Oct 07 '14 at 13:07

1 Answers1

1

If you’re using Emacs 24.4, the code you’ve posted (which I’m repeating below) should be enough.

(add-hook 'edebug-mode-hook
          (lambda ()
            (set-fringe-mode
             (set (make-local-variable 'fringe-mode)
                  (if edebug-mode '(nil . 0) 0)))))

I’m positing this as answer for completeness, I understand it doesn’t statisfy your needs. I tried to look a bit into edebug’s source code, to find a function I could advise and get a similar effect, but failed.

On Emacs 24.4

Emacs 24.4 has been in feature freeze for a while now and is unlikely to change very much until release. Plenty of people are using it daily, and I haven’t run into any problems whatsoever.
I won’t go into how to install it, as that’s another question entirely.

Malabarba
  • 22,878
  • 6
  • 78
  • 163