Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 148891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:02:21+00:00 2026-05-11T09:02:21+00:00

EDIT: I understand there is keyboard-quit (which is normally bound to C-g); but I’m

  • 0

EDIT: I understand there is keyboard-quit (which is normally bound to C-g); but I’m more interested to know about how one deals with editing functions that come with Emacs (like in this case). I run into this kind of situations from time to time when I want to change just a little bit of some build-in functions.

In emacs, when you hit M-ESC ESC (or ESC three times), you can get out of a lots of situations like transient-mark, etc. But I habitually hit the escape key (I actually remap this to a single hit of the escape key) more than I intended, and that ends up killing my windows configuration, which is quite annoying. The function keyboard-escape-quit is defined in simple.el:

(defun keyboard-escape-quit ()   'Exit the current \'mode\' (in a generalized sense of the word). This command can exit an interactive command such as `query-replace', can clear out a prefix argument or a region, can get out of the minibuffer or other recursive edit, cancel the use of the current buffer (for special-purpose buffers), or go back to just one window (by deleting all but the selected window).'   (interactive)   (cond ((eq last-command 'mode-exited) nil)     ((> (minibuffer-depth) 0)      (abort-recursive-edit))     (current-prefix-arg      nil)     ((and transient-mark-mode mark-active)      (deactivate-mark))     ((> (recursion-depth) 0)      (exit-recursive-edit))     (buffer-quit-function      (funcall buffer-quit-function))     ((not (one-window-p t))      (delete-other-windows))     ((string-match '^ \\*' (buffer-name (current-buffer)))      (bury-buffer)))) 

And I can see that I don’t want the lines:

    ((not (one-window-p t))      (delete-other-windows)) 

But what is the best way to modify this function? I can see only two ways: 1) modify simple.el 2) copy this function to my .emacs file and do the modifications there. Both ways are not really good; ideally I would like to see something on the line of defadvice, but I can’t see how I can do it in this case.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:02:22+00:00Added an answer on May 11, 2026 at 9:02 am

    You could use around advice and redefine the offending function to do what you want (i.e. one-window-p should always return t):

    (defadvice keyboard-escape-quit (around my-keyboard-escape-quit activate)   (let (orig-one-window-p)     (fset 'orig-one-window-p (symbol-function 'one-window-p))     (fset 'one-window-p (lambda (&optional nomini all-frames) t))     (unwind-protect         ad-do-it       (fset 'one-window-p (symbol-function 'orig-one-window-p))))) 

    This kind of acts like a (let …) but has to be more complicated because you need to override a function for a limited scope instead of a variable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand there are multiple questions about this on SO, but I have yet
I read all the other questions about this, but i can't understand why there
I'd be interested to know whether there are programming languages which have shorthand equality
Edit Since there were many downvotes and people who didn't understand what I'm asking
There have been a few questions on SO about the pimpl idiom , but
*edit: I understand that stackoverflow has banned all questions regarding using Microsoft's Visio. I'm
Hey can anyone help me understand how to do an edit method for my
this is an edit of the original post now that I better understand the
My current solution will suck sometimes EDIT For those who don't understand,see this example:
I do understand that there's no multiple inheritence in C#. However, I've run into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.