On June 26, 2019 6:05:39 PM GMT+05:30, Jan Nieuwenhuizen <jann...@gnu.org> wrote: >Amar Singh writes: > >> Emacsy's `set-buffer!' does not seem to work > >What are you trying to achieve? Set-buffer! is used eg in with-buffer > >--8<---------------cut here---------------start------------->8--- >(define-syntax with-buffer > (syntax-rules () > ((with-buffer buffer e ...) > (let ((old-buffer (current-buffer)) > (result *unspecified*)) > (in-out-guard > (lambda () (set-buffer! buffer)) > (lambda () e ...) > (lambda () (set-buffer! old-buffer))))))) >--8<---------------cut here---------------end--------------->8--- > >and works fine. You don't want to use it interactively. > >> and `switch-to-buffer' >> does a bit more than just switch to the given buffer(it also >re-orders >> the buffer-stack). > >Yes, it also calls buffer-exit and enter hooks; this is exactly what >Emacs does. > >> Maybe an optional argument to `switch-to-buffer' >> should be provided if the user also wants to set the current buffer >as >> most recently used in `buffer-stack'. WDYT? > >> Both, resetting buffer order, and not touching it are useful >behaviours. > >I don't think that's what we want, I'm imagining this helps you to >achieve something so I'm curious what you want to do? > >> From da20cae843753991422478598da193b5a9f6b35d Mon Sep 17 00:00:00 >2001 >> From: Amar Singh <n...@disroot.org> >> Date: Mon, 24 Jun 2019 02:22:48 +0530 >> Subject: [PATCH 1/2] buffer.scm fixes: other-buffer, next-buffer > >LGTM, applied. > >> From 1015052f51209adc766d6e1ff4f602c5a0f9f67c Mon Sep 17 00:00:00 >2001 >> From: Amar Singh <n...@disroot.org> >> Date: Tue, 25 Jun 2019 19:44:08 +0530 >> Subject: [PATCH 2/2] buffer.scm: `switch-to-buffer' takes additional >argument >> recall? > >Not yet, let's see. > >> - (mru-recall! buffer-stack buffer) >> + (if recall? (mru-recall! buffer-stack buffer)) > >(please use `when' for an if without else clause). > >janneke
>I don't think that's what we want, I'm imagining this helps you to >achieve something so I'm curious what you want to do? We want to have commands like next-buffer, previous-buffer and other-buffer with Emacs-like semantics. Imagine we have buffers: gnu.org 127.0.0.1 Messages buffer-next!: gnu.org 127.0.0.1 Messages (assume it moves through buffers in this direction) then, buffer-previous!: gnu.org Messages 127.0.0.1 but can you guess what happens when interactive versions of buffer-next! and buffer-previous! are called? next-buffer: gnu.org 127.0.0.1 gnu.org (keeps cycling between the two) prev-buffer: gnu.org Messages 127.0.0.1 this has to do with the fact that switch-to-buffer will call mru-recall!. This behaviour of switch-to-buffer is unexpected and should be optional i think. but we may also want to have(Emacs-like other-buffer) other-buffer: gnu.org 127.0.0.1 gnu.org other-buffer should look like something: (sry should have included this in the patch as well) (mru-next! buffer-stack incr) (switch-to-buffer (mru-ref buffer-stack) t) wdyt? Amar Singh<n...@disroot.org> ---------------- Sent fromK-9 Mail. Please excuse my brevity.