unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#16436: feature request: select-window-hook
@ 2014-01-14  3:48 陈育龙
  2014-01-14  7:47 ` martin rudalics
  2019-01-12  9:15 ` martin rudalics
  0 siblings, 2 replies; 3+ messages in thread
From: 陈育龙 @ 2014-01-14  3:48 UTC (permalink / raw)
  To: 16436

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

I don't know whether I missed something but I can't find a hook like
select-window-hook in stand
hooks<http://www.gnu.org/software/emacs/manual/html_node/elisp/Standard-Hooks.html>,
and I find some other emacs user has the same issue.

I really want to have a function as select-last-window for emacs, by now, I
hack it in a ugly way, and I think select-window-hook can make it better.

Thanks.

[-- Attachment #2: Type: text/html, Size: 489 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#16436: feature request: select-window-hook
  2014-01-14  3:48 bug#16436: feature request: select-window-hook 陈育龙
@ 2014-01-14  7:47 ` martin rudalics
  2019-01-12  9:15 ` martin rudalics
  1 sibling, 0 replies; 3+ messages in thread
From: martin rudalics @ 2014-01-14  7:47 UTC (permalink / raw)
  To: 陈育龙; +Cc: 16436

 > I don't know whether I missed something but I can't find a hook like
 > select-window-hook in stand
 > hooks<http://www.gnu.org/software/emacs/manual/html_node/elisp/Standard-Hooks.html>,
 > and I find some other emacs user has the same issue.
 >
 > I really want to have a function as select-last-window for emacs, by now, I
 > hack it in a ugly way, and I think select-window-hook can make it better.

Try

(defvar my-window nil)
(defvar my-last-window nil)

(defun my-last-window ()
   (unless (or (window-minibuffer-p)
	      (eq (selected-window) my-window))
     (setq my-last-window my-window)
     (setq my-window (selected-window))))

(add-hook 'buffer-list-update-hook 'my-last-window)

(defun select-last-window ()
   (interactive)
   (when (and (window-live-p my-last-window)
	     (not (eq my-last-window (selected-window))))
     (select-window my-last-window)))

martin





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#16436: feature request: select-window-hook
  2014-01-14  3:48 bug#16436: feature request: select-window-hook 陈育龙
  2014-01-14  7:47 ` martin rudalics
@ 2019-01-12  9:15 ` martin rudalics
  1 sibling, 0 replies; 3+ messages in thread
From: martin rudalics @ 2019-01-12  9:15 UTC (permalink / raw)
  To: 陈育龙, 16436

 > I don't know whether I missed something but I can't find a hook like
 > select-window-hook in stand
 > hooks<http://www.gnu.org/software/emacs/manual/html_node/elisp/Standard-Hooks.html>,
 > and I find some other emacs user has the same issue.
 >
 > I really want to have a function as select-last-window for emacs, by now, I
 > hack it in a ugly way, and I think select-window-hook can make it better.

Emacs now provides a hook called 'window-selection-change-functions'
which should fix your problem.  Please have a look.

Thanks, martin





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-12  9:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-14  3:48 bug#16436: feature request: select-window-hook 陈育龙
2014-01-14  7:47 ` martin rudalics
2019-01-12  9:15 ` martin rudalics

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