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 7405297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:22:58+00:00 2026-05-29T05:22:58+00:00

I am trying to define my minor mode, mimicking it after isearch-mode (since it

  • 0

I am trying to define my minor mode, mimicking it after isearch-mode (since it is kind of an interactive search-and-replace tool, I thought it might be a good starting point). My commands work well (tested on global keybindings), but I have serious problems with binding them locally (in the minor mode map) to some keys, namely TAB and RET. I’m doing something like this:

(defvar my-mode-map
  (let ((map (make-sparse-keymap)))
    (define-key map "\s" 'my-command)
    (define-key map "\t" 'another-one)
    (define-key map "\r" 'yet-another)
    map))

(Of course, I did put my keymap into minor-mode-map-alist.)

While the space-bound command works fine, TAB and RET somehow do not. If I change, eg, “\t” to “[f11]”, it works fine. I tried using the “vector notation” ([?\t]) with identical results (after C-h C-v-ing my keymap it was not surprising). What might be happening?

Edit: to clarify the problem, I tried to isolate it and I came up with the following code. Assume that I want to have an artificial, rather minimal minor mode tabbang in which the TAB key inserts an exclamation mark. I’m doing this:

(defvar tabbang-mode)
(add-to-list 'minor-mode-alist '(tabbang-mode tabbang-mode) t)

(defvar tabbang-mode-map
  (let ((map (make-sparse-keymap)))
    (define-key map [?\t] 'tabbang-insert-bang)
    (define-key map [?\C-\t] 'tabbang-insert-bang)
    (define-key map [f11] 'tabbang-insert-bang)
    (define-key map [?\r] 'tabbang-done)
    (define-key map [t] 'tabbang-other-char)
    map))
(add-to-list 'minor-mode-map-alist `(tabbang-mode . ,tabbang-mode-map) t)

(defun tabbang-insert-bang ()
  (interactive)
  (insert "!"))

(defun tabbang-mode ()
  (interactive)
  (setq tabbang-mode " tabbang"))

(defun tabbang-other-char ()
  (interactive)
  (tabbang-done)
  (setq unread-command-events
    (append (listify-key-sequence (this-command-keys))
        unread-command-events)))

(defun tabbang-done ()
  (interactive)
  (setq tabbang-mode nil))

While in my tabbang-mode, “other” keys correctly exit the mode and insert themselves, f11 inserts a bang (correct), TAB does not exit the mode (correct), but inserts nothing (wrong), C-TAB yields “undefined key” error (definitely wrong), and RET exits the mode (correct), but inserts a newline (wrong). And I tried on a “fresh” emacs (without loading site-file and my .emacs), so that no other code should intervene (I was afraid of yasnippet somehow capturing TAB etc.) What is going on?

  • 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. Editorial Team
    Editorial Team
    2026-05-29T05:22:59+00:00Added an answer on May 29, 2026 at 5:22 am

    I believe you can change them with (kbd "<tab>") and (kbd "<return>") in place of “\t” and “\r” respectively.


    In response to your edit, yes, the following works perfectly for me:

    ...
    (defvar tabbang-mode-map
      (let ((map (make-sparse-keymap)))
        (define-key map (kbd "<tab>") 'tabbang-insert-bang)
        (define-key map (kbd "<C-tab>") 'tabbang-insert-bang)
        (define-key map (kbd "<f11>") 'tabbang-insert-bang)
        (define-key map (kbd "<return>") 'tabbang-done)
        (define-key map (kbd "t") 'tabbang-other-char)
        map))
    (add-to-list 'minor-mode-map-alist `(tabbang-mode . ,tabbang-mode-map) t)
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im trying to define the condition SR.PRODUCT_STOCK2 > 0 inside the sql code, since
Im trying to define a select tag in my view. My view looks like
I'm trying to define a method in my vb.net interface that will only accept
I am trying to define a dynamic var in a different namespace. The Lobos
I am trying to define a number of classes based on an abstract base
I am trying to define an abstract class that has operators to compare two
I'm trying to define a very simple function in Drools as below: import java.util.List;
I am trying to define nested modules, but I couldn't find any complete explanations
I'm trying to define a service endpoint in my web.config file so that I
I'm trying to define a new array through a where query but I can

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.