Add support for fancy frame title

Acked-by: Uri Sharf <uri.sharf@gmail.com>
This commit is contained in:
Uri Sharf 2015-07-10 15:57:18 +02:00 committed by syl20bnr
parent a488a56e8e
commit cb30ec1df8
3 changed files with 54 additions and 0 deletions

View File

@ -139,6 +139,10 @@ whenever you start Emacs.")
Press `SPC T n' to cycle to the next theme in the list (works great
with 2 themes variants, one dark and one light")
(defvar dotspacemacs-frame-title-format nil
"Default format string for a frame title bar, using the
original format spec, and additional customizations.")
(defvar dotspacemacs-colorize-cursor-according-to-state t
"If non nil the cursor color matches the state color in GUI Emacs.")
@ -597,6 +601,51 @@ If ARG is non nil then Ask questions to the user before installing the dotfile."
(load dotspacemacs))
(dotspacemacs/safe-load)))))
(defun spacemacs/frame-title-prepare ()
"A string is printed verbatim except for %-constructs.
%a -- prints the `abbreviated-file-name', or `buffer-name'
%t -- prints `projectile-project-name'
%I -- prints `invocation-name'
%S -- prints `system-name'
%U -- prints contents of $USER
%b -- prints buffer name
%f -- prints visited file name
%F -- prints frame name
%s -- prints process status
%p -- prints percent of buffer above top of window, or Top, Bot or All
%P -- prints percent of buffer above bottom of window, perhaps plus Top, or
print Bottom or All
%m -- prints mode name
%n -- prints Narrow if appropriate
%z -- prints mnemonics of buffer, terminal, and keyboard coding systems
%Z -- like %z, but including the end-of-line format"
(let* ((fs (format-spec-make
?a (abbreviate-file-name (or (buffer-file-name) (buffer-name)))
?t (if (boundp 'projectile-mode) (projectile-project-name) "-")
?S system-name
?I invocation-name
?U (or (getenv "USER") "")
?b "%b"
?f "%f"
?F "%F"
?* "%*"
?+ "%+"
?s "%s"
?l "%l"
?c "%c"
?p "%p"
?P "%P"
?m "%m"
?n "%n"
?z "%z"
?Z "%Z"
?[ "%["
?] "%]"
?% "%%"
?- "%-"
)))
(format-spec dotspacemacs-frame-title-format fs)))
(defun dotspacemacs/safe-load ()
"Error recovery from malformed .spacemacs.
Loads default .spacemacs template and suspends pruning of orphan packages.

View File

@ -106,6 +106,9 @@ the final step of executing code in `emacs-startup-hook'.")
(configuration-layer/initialize)
;; theme
(spacemacs/load-default-theme spacemacs--fallback-theme)
;; frame title init
(when (and (display-graphic-p) dotspacemacs-frame-title-format)
(setq frame-title-format '((:eval (spacemacs/frame-title-prepare)))))
;; font
(spacemacs|do-after-display-system-init
;; If you are thinking to remove this call to `message', think twice. You'll

View File

@ -291,6 +291,8 @@ values."
;; specified with an installed package.
;; Not used for now. (default nil)
dotspacemacs-default-package-repository nil
;; Format specification for setting the frame title.
dotspacemacs-frame-title-format "%I@%S"
;; Delete whitespace while saving buffer. Possible values are `all'
;; to aggressively delete empty line and long sequences of whitespace,
;; `trailing' to delete only the whitespace at end of lines, `changed' to