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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:45:46+00:00 2026-05-29T11:45:46+00:00

all. I decided to hack iswitchb this morning, and found a confusing thing. Usually,when

  • 0

all.

I decided to hack iswitchb this morning, and found a confusing thing.

Usually,when we command iswitchb,we got someting in minibuffer like:

iswitch {buffer1,buffer2 …}

What in braces is the completions, as we typing its number
is shrinking.

And I didn’t find how iswitchb achieved this when hacking on
its code (sorry for my dullness ).

This is original iswitchb-read-buffer with doc-string ripped
off:

(defun iswitchb-read-buffer (prompt &optional default require-match
                    start matches-set)
  (let
      (
       buf-sel
       iswitchb-final-text
       (icomplete-mode nil) ;; prevent icomplete starting up
       )

    (iswitchb-define-mode-map)
    (setq iswitchb-exit nil)
    (setq iswitchb-default
      (if (bufferp default)
          (buffer-name default)
        default))
    (setq iswitchb-text (or start ""))
    (unless matches-set
      (setq iswitchb-rescan t)
      (iswitchb-make-buflist iswitchb-default)
      (iswitchb-set-matches))
    (let
    ((minibuffer-local-completion-map iswitchb-mode-map)
     ;; Record the minibuffer depth that we expect to find once
     ;; the minibuffer is set up and iswitchb-entryfn-p is called.
     (iswitchb-minibuf-depth (1+ (minibuffer-depth)))
     (iswitchb-require-match require-match))
      ;; prompt the user for the buffer name
      (setq iswitchb-final-text (completing-read
                 prompt       ;the prompt
                 '(("dummy" . 1)) ;table
                 nil          ;predicate
                 nil ;require-match [handled elsewhere]
                 start  ;initial-contents
                 'iswitchb-history)))
    (if (and (not (eq iswitchb-exit 'usefirst))
         (get-buffer iswitchb-final-text))
    ;; This happens for example if the buffer was chosen with the mouse.
    (setq iswitchb-matches (list iswitchb-final-text)
          iswitchb-virtual-buffers nil))

    ;; If no buffer matched, but a virtual buffer was selected, visit
    ;; that file now and act as though that buffer had been selected.
    (if (and iswitchb-virtual-buffers
         (not (iswitchb-existing-buffer-p)))
    (let ((virt (car iswitchb-virtual-buffers))
          (new-buf))
      ;; Keep the name of the buffer returned by find-file-noselect, as 
      ;; the buffer 'virt' could be a symlink to a file of a different name.
      (setq new-buf (buffer-name (find-file-noselect (cdr virt))))
      (setq iswitchb-matches (list new-buf)
        iswitchb-virtual-buffers nil)))

    ;; Handling the require-match must be done in a better way.
    (if (and require-match
         (not (iswitchb-existing-buffer-p)))
    (error "Must specify valid buffer"))

    (if (or (eq iswitchb-exit 'takeprompt)
        (null iswitchb-matches))
    (setq buf-sel iswitchb-final-text)
      ;; else take head of list
      (setq buf-sel (car iswitchb-matches)))

    ;; Or possibly choose the default buffer
    (if  (equal iswitchb-final-text "")
    (setq buf-sel (car iswitchb-matches)))

    buf-sel))

And this is the part of iswitchb-read buffer,which I thought
is responsible for functioning completion mechanism.

 (defun iswitchb-read-buffer (prompt &optional default require-match
                        start matches-set)
    (let
          (
           (iswitchb-minibuf-depth (1+ (minibuffer-depth)))
           )
       ;; prompt the user for the buffer name
       (completing-read
                 prompt       ;the prompt
                 '(("dummy" . 1)) ;table
                 nil          ;predicate
                 nil ;require-match [handled elsewhere]
                 start  ;initial-contents
                 'iswitchb-history)))

Eval

 (iswitchb-read-buffer "Test: ")

resulting

Test: {buffer1,buffer2,…}

So, I think I’m right.

So,what confused me is how can sexp:

(iswitchb-minibuf-depth (1+ (minibuffer-depth)))

has effect on what echos in minibuffer. Comment this
sexp,or replace iswitchb-minibuffer-depth with another
variable, the completions will disappear.

Any advice?

  • 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-29T11:45:48+00:00Added an answer on May 29, 2026 at 11:45 am

    This variable is used in iswitchb-entryfn-p which is called from iswitchb-minibuffer-setup

    (defun iswitchb-minibuffer-setup ()
      "Set up minibuffer for `iswitchb-buffer'.
    Copied from `icomplete-minibuffer-setup-hook'."
      (when (iswitchb-entryfn-p)
        (set (make-local-variable 'iswitchb-use-mycompletion) t)
        (add-hook 'pre-command-hook 'iswitchb-pre-command nil t)
        (add-hook 'post-command-hook 'iswitchb-post-command nil t)
        (run-hooks 'iswitchb-minibuffer-setup-hook)))
    

    When iswitchb-minibuf-depth is null then iswitchb-entryfn-p is null and the setup is not done.

    The iswitchb-minibuffer-setup is a hook which is added to the iswitchb-mode.

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

Sidebar

Related Questions

Good morning all, After a day of googling, I’m at a loss. I decided
I decided to look a bit into python. I found this book began to
I have decided that all my WPF pages need to register a routed event.
With all the hype around MVC (and rightly so) I've decided to give it
I've decided to go with jQuery for all my AJAX related client side needs.
All the articles I've found via google are either obsolete or contradict one another.
I decided to rewrite all our Bash scripts in Python (there are not so
I've decided to put all my constants in a neat class called constants, and
In my last project i decided to use Entity Framework and it was all
I had recently started learning Python, and with all the research I decided it

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.