* switch-to-buffer-regexp.el + helper/interface file
@ 2020-12-19 3:03 Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 0 replies; only message in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-19 3:03 UTC (permalink / raw)
To: help-gnu-emacs
Got this old idea working, finally! Works great :) And it
didn't take me very long, either... 2 files. See comments
for instructions.
;;; -*- lexical-binding: t -*-
;;;
;;; this file:
;;; http://user.it.uu.se/~embe8573/emacs-init/switch-to-buffer-regexp.el
;;; https://dataswamp.org/~incal/emacs-init/switch-to-buffer-regexp.el
(require 'cl-lib)
(defun buffer-names ()
(mapcar #'buffer-name (buffer-list)) )
(defun switch-to-buffer-regexp (buf-re)
(let*((ori-buf (buffer-name (current-buffer)))
(hits (cl-remove-if-not
(lambda (b) (string-match buf-re b)) (buffer-names)) ))
(when hits
(let ((new-hits (cl-remove ori-buf hits)))
(when new-hits
(when (string-match buf-re ori-buf)
(bury-buffer ori-buf) )
(switch-to-buffer (car new-hits)) )))))
;; try it!
;; (require 'gnus)
;; (dotimes (i 4) (gnus-post-news 'post "")) ; create 4 posts
(global-set-key "\C-cu" (lambda () (interactive) (switch-to-buffer-regexp "\*unsent posting\*.*")))
(global-set-key "\C-ck" (lambda () (interactive) (switch-to-buffer-regexp ".*\.txt")))
;; hit again to iterate
(provide 'switch-to-buffer-regexp)
;;; -*- lexical-binding: t -*-
;;;
;;; this file:
;;; http://user.it.uu.se/~embe8573/emacs-init/switch-to-buffer.el
;;; https://dataswamp.org/~incal/emacs-init/switch-to-buffer.el
;;;
;;; bind these and similar to one-button keys, e.g. from the buffer-menu
(require 'switch-to-buffer-regexp)
(defun switch-to-compilation-buffer ()
(interactive)
(switch-to-buffer-regexp "\*compilation\*") )
(defun switch-to-help-buffer ()
(interactive)
(switch-to-buffer-regexp "\*Help\*") )
(defun switch-to-info-buffer ()
(interactive)
(switch-to-buffer-regexp "\*info\*") )
(defun switch-to-manpage-buffer ()
(interactive)
(switch-to-buffer-regexp "\*Man .*\*") )
(defun switch-to-summary-buffer ()
(interactive)
(switch-to-buffer-regexp "\*Summary.*\*") )
(defun switch-to-article-buffer ()
(interactive)
(switch-to-buffer-regexp "\*Article\*") )
(defun switch-to-unsent-buffer ()
(interactive)
(switch-to-buffer-regexp "\*unsent .*\*") )
(provide 'switch-to-buffer)
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-12-19 3:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-19 3:03 switch-to-buffer-regexp.el + helper/interface file Emanuel Berg via Users list for the GNU Emacs text editor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).