[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#51176: eww switch buffer by title
From: |
Yuchen Pei |
Subject: |
bug#51176: eww switch buffer by title |
Date: |
Thu, 14 Oct 2021 10:48:08 +1100 |
User-agent: |
mu4e 1.4.13; emacs 27.2 |
Juri Linkov <juri@linkov.net> writes:
I think in that case, perhaps it would make more sense to
just rename
the eww buffer to have the title in the buffer name? Then
the normal
buffer switching commands would work automatically.
In Info, forking commands (such as 'Info-follow-nearest-node
FORK')
create a new buffer with the Info node name in its buffer
name, e.g.
*info-TITLE*. So instead of current *eww*<2>, eww could use
the same
format *eww-TITLE*, or uniquify-like angle brackets
*eww<TITLE>*.
Yup, that's what I meant. The wrinkle here is that we don't
know the
title until we've fetched the HTML, so the buffer has to be
renamed
after rendering.
I see. Then maybe in the existing hook `eww-after-render-hook'?
This is
the standard way to customize buffer renaming, e.g. I have a lot
of such
(add-hook 'occur-hook 'occur-rename-buffer) for customizing
different modes.
On a related note, I also have a function defined in a similar
fashion switching to a shell buffer by prompts. Are people
interested in having this as well? I don't see a shell hook like
eww-after-render-hook that can achieve this though.
(defun get-comint-prompt ()
(save-excursion
;; more useful than (beginning-of-line) to move past sticky
part
(forward-line 0)
(let ((end
;; font-lock-face should be comint-highlight-prompt
(next-single-char-property-change (point)
'font-lock-face)))
(buffer-substring-no-properties (point) end))))
(defun shell-switch-by-prompt (prompt-and-buffer)
"Switches to a shell with selected prompt."
(interactive
(list
(let ((com-table))
(dolist (buffer (buffer-list))
(with-current-buffer buffer
(when (equal major-mode 'shell-mode)
(add-to-list
'com-table
(concat (get-comint-prompt)
(propertize (concat " " (buffer-name))
'invisible t))))))
(completing-read "Shell prompt: " com-table))))
(string-match "^.* \\(.*\\)$" prompt-and-buffer)
(switch-to-buffer (match-string 1 prompt-and-buffer)))
--
Best,
Yuchen
PGP Key: 47F9 D050 1E11 8879 9040 4941 2126 7E93 EF86 DFD0
<https://ypei.me/assets/ypei-pubkey.txt>
signature.asc
Description: PGP signature
- bug#51176: eww switch buffer by title, (continued)
- bug#51176: eww switch buffer by title, Lars Ingebrigtsen, 2021/10/15
- bug#51176: eww switch buffer by title, Jose Antonio Ortega Ruiz, 2021/10/15
- bug#51176: eww switch buffer by title, Protesilaos Stavrou, 2021/10/16
- bug#51176: eww switch buffer by title, Protesilaos Stavrou, 2021/10/16
- bug#51176: eww switch buffer by title, Jose Antonio Ortega Ruiz, 2021/10/16
- bug#51176: eww switch buffer by title, Lars Ingebrigtsen, 2021/10/18
- bug#51176: eww switch buffer by title, Protesilaos Stavrou, 2021/10/18
- bug#51176: eww switch buffer by title, Lars Ingebrigtsen, 2021/10/18
- bug#51176: eww switch buffer by title, Yuchen Pei, 2021/10/13
- bug#51176: [External] : bug#51176: eww switch buffer by title, Drew Adams, 2021/10/13
- bug#51176: eww switch buffer by title,
Yuchen Pei <=
- bug#51176: eww switch buffer by title, Lars Ingebrigtsen, 2021/10/14
- bug#51176: eww switch buffer by title, Juri Linkov, 2021/10/14