unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuchen Pei <hi@ypei.me>
To: Juri Linkov <juri@linkov.net>
Cc: Lars Ingebrigtsen <larsi@gnus.org>, 51176@debbugs.gnu.org
Subject: bug#51176: eww switch buffer by title
Date: Thu, 14 Oct 2021 10:48:08 +1100	[thread overview]
Message-ID: <87a6jc4hc7.fsf@ypei.me> (raw)
In-Reply-To: <875yu0x256.fsf@mail.linkov.net>

[-- Attachment #1: Type: text/plain, Size: 2252 bytes --]


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>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 243 bytes --]

  parent reply	other threads:[~2021-10-13 23:48 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-13  4:56 bug#51176: eww switch buffer by title Yuchen Pei
2021-10-13 11:52 ` Lars Ingebrigtsen
2021-10-13 12:15   ` Yuchen Pei
2021-10-13 12:54     ` Lars Ingebrigtsen
2021-10-13 16:28       ` Juri Linkov
2021-10-13 16:47         ` Lars Ingebrigtsen
2021-10-13 17:31           ` Juri Linkov
2021-10-13 18:14             ` Lars Ingebrigtsen
2021-10-13 20:31               ` Protesilaos Stavrou
2021-10-13 20:33                 ` Lars Ingebrigtsen
2021-10-15  6:31                   ` Protesilaos Stavrou
2021-10-15  8:32                     ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-10-15 10:35                     ` Lars Ingebrigtsen
2021-10-15 11:22                       ` Protesilaos Stavrou
2021-10-15 12:13                         ` Lars Ingebrigtsen
2021-10-15 13:25                           ` Jose Antonio Ortega Ruiz
2021-10-15 14:00                             ` Lars Ingebrigtsen
2021-10-15 19:59                               ` Jose Antonio Ortega Ruiz
2021-10-16  4:16                                 ` Protesilaos Stavrou
2021-10-16  4:20                                   ` Protesilaos Stavrou
2021-10-16 14:31                                   ` Jose Antonio Ortega Ruiz
2021-10-18  6:43                                   ` Lars Ingebrigtsen
2021-10-18  7:15                                     ` Protesilaos Stavrou
2021-10-18  7:16                                       ` Lars Ingebrigtsen
2021-10-13 21:26                 ` Yuchen Pei
2021-10-14  0:16                 ` bug#51176: [External] : " Drew Adams
2021-10-13 23:48             ` Yuchen Pei [this message]
2021-10-14 11:06               ` Lars Ingebrigtsen
2021-10-14 16:05               ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a6jc4hc7.fsf@ypei.me \
    --to=hi@ypei.me \
    --cc=51176@debbugs.gnu.org \
    --cc=juri@linkov.net \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).