Random selection of startup banner

This commit is contained in:
syl20bnr 2014-12-25 15:24:26 -05:00
parent 2554d16c16
commit 714d8b9bf5
6 changed files with 42 additions and 9 deletions

View file

@ -0,0 +1,7 @@
Welcome to
███████╗██████╗**█████╗**██████╗███████╗███╗***███╗*█████╗**██████╗███████╗ B
██╔════╝██╔══██╗██╔══██╗██╔════╝██╔════╝████╗*████║██╔══██╗██╔════╝██╔════╝ E
███████╗██████╔╝███████║██║*****█████╗**██╔████╔██║███████║██║*****███████╗ T
╚════██║██╔═══╝*██╔══██║██║*****██╔══╝**██║╚██╔╝██║██╔══██║██║*****╚════██║ A
███████║██║*****██║**██║╚██████╗███████╗██║*╚═╝*██║██║**██║╚██████╗███████║
╚══════╝╚═╝*****╚═╝**╚═╝*╚═════╝╚══════╝╚═╝*****╚═╝╚═╝**╚═╝*╚═════╝╚══════╝

View file

@ -0,0 +1,8 @@
┏━━━┓
┃┏━┓┃ Welcome to
┃┗━━┓╋╋╋╋┏━━┓╋╋╋╋┏━━┓╋╋╋╋┏━━┓╋╋╋╋┏━━┓╋╋╋╋┏┓┏┓╋╋╋╋┏━━┓╋╋╋╋┏━━┓╋╋╋╋┏━━┓ b
┗━━┓┃┏━━┓┃┏┓┃┏━━┓┃┏┓┃┏━━┓┃┏━┛┏━━┓┃┃━┫┏━━┓┃┗┛┃┏━━┓┃┏┓┃┏━━┓┃┏━┛┏━━┓┃━━┫ e
┃┗━┛┃┗━━┛┃┗┛┃┗━━┛┃┏┓┃┗━━┛┃┗━┓┗━━┛┃┃━┫┗━━┛┃┃┃┃┗━━┛┃┏┓┃┗━━┛┃┗━┓┗━━┛┣━━┃ t
┗━━━┛╋╋╋╋┃┏━┛╋╋╋╋┗┛┗┛╋╋╋╋┗━━┛╋╋╋╋┗━━┛╋╋╋╋┗┻┻┛╋╋╋╋┗┛┗┛╋╋╋╋┗━━┛╋╋╋╋┗━━┛ a
╋╋╋╋╋╋╋╋╋┃┃[The best editor is neither Emacs nor Vim, it's Emacs+Vim]
╋╋╋╋╋╋╋╋╋┗┛

View file

@ -1,6 +1,10 @@
(require 'dotspacemacs) (require 'dotspacemacs)
(require 'ht) (require 'ht)
(defconst configuration-layer-template-directory
(expand-file-name (concat spacemacs-core-directory "templates/"))
"Configuration layer templates directory.")
(defconst configuration-layer-contrib-directory (defconst configuration-layer-contrib-directory
(expand-file-name (concat user-emacs-directory "contrib/")) (expand-file-name (concat user-emacs-directory "contrib/"))
"Spacemacs contribution layers base directory.") "Spacemacs contribution layers base directory.")
@ -91,7 +95,7 @@ NAME."
(defun configuration-layer//copy-template (template) (defun configuration-layer//copy-template (template)
"Copy and replace special values of TEMPLATE to LAYER_DIR." "Copy and replace special values of TEMPLATE to LAYER_DIR."
(let ((src (concat spacemacs-template-directory (let ((src (concat configuration-layer-template-directory
(format "%s.template" template))) (format "%s.template" template)))
(dest (concat (configuration-layer//get-private-layer-dir name) (dest (concat (configuration-layer//get-private-layer-dir name)
(format "%s.el" template)))) (format "%s.el" template))))

View file

@ -1,7 +1,11 @@
(defconst dotspacemacs-template-directory
(expand-file-name (concat spacemacs-core-directory "templates/"))
"Templates directory.")
(defvar dotspacemacs-configuration-layer-path '() (defvar dotspacemacs-configuration-layer-path '()
"List of additional paths where to look for configuration layers. "List of additional paths where to look for configuration layers.
Paths must have a trailing slash (ie. `~/.mycontribs/')" Paths must have a trailing slash (ie. `~/.mycontribs/')"
) )
(defvar dotspacemacs-configuration-layers '() (defvar dotspacemacs-configuration-layers '()
"list of contribution to load." "list of contribution to load."
@ -73,7 +77,7 @@ before installing the file if the destination already exists."
dotfile)) dotfile))
t))) t)))
(when install (when install
(copy-file (concat spacemacs-template-directory (copy-file (concat dotspacemacs-template-directory
".spacemacs.template") dotfile t) ".spacemacs.template") dotfile t)
(message "%s has been installed." dotfile)))) (message "%s has been installed." dotfile))))

View file

@ -9,9 +9,9 @@
"Spacemacs core directory.") "Spacemacs core directory.")
(add-to-list 'load-path spacemacs-core-directory) (add-to-list 'load-path spacemacs-core-directory)
(defconst spacemacs-template-directory (defconst spacemacs-banner-directory
(expand-file-name (concat spacemacs-core-directory "templates/")) (expand-file-name (concat spacemacs-core-directory "banners/"))
"Spacemacs templates directory.") "Spacemacs banners directory.")
;; additional paths ;; additional paths
(defconst user-home-directory (defconst user-home-directory
@ -95,9 +95,7 @@
(`w32 (spacemacs/set-font font 9)) (`w32 (spacemacs/set-font font 9))
(other (spacemacs/set-font font 10))))) (other (spacemacs/set-font font 10)))))
;; banner ;; banner
(let ((buffer-read-only nil)) (spacemacs//insert-banner)
(insert-file-contents (concat spacemacs-core-directory "banner.txt"))
(spacemacs/insert-buttons))
;; bind-key is required by use-package ;; bind-key is required by use-package
(spacemacs/load-or-install-package 'bind-key t) (spacemacs/load-or-install-package 'bind-key t)
(spacemacs/load-or-install-package 'use-package t) (spacemacs/load-or-install-package 'use-package t)
@ -161,6 +159,18 @@ If LOG is non-nil a message is displayed in spacemacs-mode buffer."
(add-to-list 'default-frame-alist (cons 'font fontstr)) (add-to-list 'default-frame-alist (cons 'font fontstr))
(set-default-font fontstr))) (set-default-font fontstr)))
(defun spacemacs//insert-banner ()
"Choose a banner and insert in spacemacs buffer."
(let* ((files (directory-files spacemacs-banner-directory nil nil 'nosort))
(count (length files))
;; -2 to remove `.' `..'
(choice (random (- count 2)))
(banner (format "%03d-banner.txt" choice))
(buffer-read-only nil))
(message "%s" count)
(insert-file-contents (concat spacemacs-banner-directory banner))
(spacemacs/insert-buttons)))
(defun spacemacs/message (msg &rest args) (defun spacemacs/message (msg &rest args)
"Display MSG in message prepended with '(Spacemacs)'." "Display MSG in message prepended with '(Spacemacs)'."
(message "(Spacemacs) %s" (apply 'format msg args))) (message "(Spacemacs) %s" (apply 'format msg args)))