🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Derek Ney Mon, 10 Feb 1992 15:44
Routines to set x-window titles and icon-titles
#1638
Author: Derek Ney
Date: Mon, 10 Feb 1992 15:44
148 lines
6545 bytes
I have always been annoyed that the titles for epoch screens often
do not reflect the files being edited in the screens. I wrote these
routines such that this could be fixed. Note that this is the first
real e-lisp I have written, so that the code may be ugly. Helpful
criticism is always appreciated-but use at your own risk. This code
should be loaded with (load-file title.el) in you .emacs file.

-Derek Ney
derek@boingo.med.jhu.edu

;;-----------------------------beginning of title.el-----------------
;; File:         title.el
;; Description:  Set x-window titles for epoch screens
;; Author:       Derek Ney (derek@boingo.med.jhu.edu)
;; Created:      7Feb92
;; Version:      1.0

;; E-lisp routines for Epoch that set the title of the window
;; and icon for an Epoch screen to the names of the buffers
;; being visited in that screen

;; Written by Derek Ney, February 1992
;; Copyright 1992 Derek Ney
;; Everyone is granted permission to copy, modify and redistribute
;; this file, provided the people they give it to can.

;; This set of routines attempts to keep the X-window title and
;; icon title names to be the same as the names of the buffers
;; being visited in the X-window epoch screen. It allows the
;; user to specify a list of excluded buffer names which are
;; never shown in the title (such as "*Buffer List*" etc.).
;; The title is prefixed with the string in the variable
;; "epoch::window-title-prefix". Also, the routines by default
;; ignore buffers with names starting with space. This behaviour
;; can be turned off by setting the variable 
;; "epoch::exclude-buffer-names-starting-with-space" to nil.
;; These routines use the hook "set-window-buffer-hook" found
;; in src/window.c. If this is already being used by you for
;; something, these routines will conflict with it.
;;
;; Known problems: The code seems to work well. However, the titles
;; and the visited buffer names can get out of sync when the user
;; does certain things. The function "delete-other-windows" usually
;; bound to "^X1" does not update the windows using the hook that
;; these routines use. Also, if the user cancels a find file in which
;; a list of file-name completions have been asked for, the titles
;; are not updated to show the correct buffer names. I would be
;; interested in any patches that would correct this behaviour. 
;; For now, I suggest that you bind the command defined here as
;; "epoch::refresh-screen-titles" to a key, so that in these cases
;; the titles can be reset with a quick key stroke. 

;; Note that this is my first attempt at E-lisp code and I didn't
;; even have the reference manual. Please forgive any blunders.

(defvar epoch::exclude-buffer-names-from-window-titles 
  (list "*Buffer List*" "*Help*" nil )
  "A list of buffer names which you do not ever want displayed
in a window title")

(defvar epoch::exclude-buffer-names-starting-with-space t
  "Buffer names starting with space are generally temporary buffers for 
help or permenant things like minibuffers. If this variable is true
then these buffer names are never displayed.")

(defvar epoch::window-title-prefix "Epoch:" 
  "The prefix put before the list of currently displayed buffers for a window")

(defun epoch::possibly-append-buffer-name (buffer names)
  "This function appends the name of the given buffer to a list of strings
given as its second argument. It is appended only if the buffer name is not in the list of excluded files given by exclude-buffer-names-from-window-titles
and it is not already in the list. It returns the list"

  (setq the-name (buffer-name buffer))

  (setq exclude nil)
  (setq list-of-names names)

  (if epoch::exclude-buffer-names-starting-with-space 
      (if (equal (substring the-name 0 1) " ")
	  (setq exclude t)))

  (while list-of-names
    (if (equal the-name (car list-of-names)) (setq exclude t))
    (setq list-of-names (cdr list-of-names)))
  
  (setq exclusion epoch::exclude-buffer-names-from-window-titles)
  (while exclusion
    (if (equal the-name (car exclusion)) (setq exclude t))
    (setq exclusion (cdr exclusion)))

  (if (not exclude)
      (setq names (append (list the-name) names)))

  names)


(defun epoch::set-titles-for-screen (the-screen)
  "Sets the epoch screen name based upon all of the windows contained
in the screen given as an argument."  

  (setq first-window (epoch::first-window the-screen))
  (setq a-window first-window)

  (setq name-list (epoch::possibly-append-buffer-name (window-buffer a-window)
						      nil))
  (setq a-window (next-window a-window))

  (while (not (eq a-window first-window))
    (setq name-list (epoch::possibly-append-buffer-name 
		     (window-buffer a-window)
		     name-list))
    (setq a-window (next-window a-window)))

  (setq whole-name epoch::window-title-prefix)
  (setq whole-name (concat whole-name (car name-list)))
  (setq name-list (cdr name-list))
  (while name-list
    (setq whole-name (concat whole-name "," (car name-list)))
    (setq name-list (cdr name-list)))
  
  (epoch::title whole-name the-screen)
  (epoch::icon-name whole-name the-screen)
  nil)

(defun epoch::set-titles-from-window (window)
  "Sets the epoch screen name based upon all of the windows contained
in the screen that owns the window given as the argument."

  (epoch::set-titles-for-screen (epoch::screen-of-window window))
  )

(defun epoch::refresh-screen-titles ()
  "Goes thru all of the mapped screens and refreshes the window
and icon titles."
  
  (interactive)
  (setq screens (epoch::screen-list t))
  (while screens
    (epoch::set-titles-for-screen (car screens))
    (setq screens (cdr screens)))
  )

(setq set-window-buffer-hook 'epoch::set-titles-from-window)

(epoch::refresh-screen-titles)

;; -------------------end of title.el-----------------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads