diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000000..ea0554f0fcd6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1 @@ +Here's some demo content for the changelog. diff --git a/core/core-dotspacemacs.el b/core/core-dotspacemacs.el index b4ea0afd1d5f..9458a0afb6f0 100644 --- a/core/core-dotspacemacs.el +++ b/core/core-dotspacemacs.el @@ -31,6 +31,8 @@ banner, `random' chooses a random text banner in `core/banners' directory. A string value must be a path to a .PNG file. If the value is nil then no banner is displayed.") +(defvar dotspacemacs-always-show-changelog t) + (defvar dotspacemacs-configuration-layers '() "List of configuration layers to load. If it is the symbol `all' instead of a list then all discovered layers will be installed.") diff --git a/core/core-load-paths.el b/core/core-load-paths.el index 1e899873cac9..402fb2f932ed 100644 --- a/core/core-load-paths.el +++ b/core/core-load-paths.el @@ -27,6 +27,9 @@ (defconst spacemacs-cache-directory (expand-file-name (concat user-emacs-directory ".cache/")) "Spacemacs storage area for persistent files.") +(defconst spacemacs-changelog-file + (expand-file-name (concat user-emacs-directory "CHANGELOG.md")) + "Spacemacs changelog") (defconst user-home-directory (expand-file-name "~/") diff --git a/core/core-spacemacs-buffer.el b/core/core-spacemacs-buffer.el index a6d1699fd058..2a7510347be6 100644 --- a/core/core-spacemacs-buffer.el +++ b/core/core-spacemacs-buffer.el @@ -15,6 +15,8 @@ (defconst spacemacs--banner-length 75 "Width of a banner.") +(defvar spacemacs--changelog-widgets ()) + (defun spacemacs//insert-banner-and-buttons () "Choose a banner accordingly to `dotspacemacs-startup-banner'and insert it in spacemacs buffer along whith quick buttons underneath. @@ -31,6 +33,8 @@ Doge special text banner can be reachable via `999', `doge' or `random*'. (insert-file-contents banner)) (spacemacs//inject-version) (spacemacs/insert-buttons) + (when (eq t dotspacemacs-always-show-changelog) + (spacemacs/toggle-changelog)) (spacemacs//redisplay)))) (defun spacemacs//choose-banner () @@ -103,6 +107,24 @@ buffer, right justified." (delete-char (length injected)) (insert injected)))) +(defun spacemacs//insert-changelog () + (save-excursion + (beginning-of-buffer) + (search-forward "Spacemacs\]") + (next-line) + (let* ((file-contents (with-temp-buffer (insert-file-contents spacemacs-changelog-file) (buffer-string))) + (changelog-header "\nCHANGELOG")) + (setq spacemacs--changelog-widgets (cons (widget-create 'text changelog-header) spacemacs--changelog-widgets)) + (setq spacemacs--changelog-widgets (cons (widget-create 'text (concat "\n" file-contents)) spacemacs--changelog-widgets))))) + +(defun spacemacs/toggle-changelog () + (if (eq spacemacs--changelog-widgets nil) + (spacemacs//insert-changelog) + (mapc (lambda (el) + (widget-delete el) + (setq spacemacs--changelog-widgets (remove el spacemacs--changelog-widgets))) + spacemacs--changelog-widgets))) + (defun spacemacs/set-mode-line (format) "Set mode-line format for spacemacs buffer." (with-current-buffer (get-buffer-create "*spacemacs*") @@ -153,43 +175,78 @@ buffer, right justified." (defun spacemacs/insert-buttons () (goto-char (point-max)) (insert " ") - (insert-button "[Homepage]" 'action - (lambda (b) (browse-url "https://github.com/syl20bnr/spacemacs")) - 'follow-link t 'help-echo "Open the Spacemacs Github page in your browser.") + (widget-create 'url-link + :tag "Homepage" + :help-echo "Open the Spacemacs Github page in your browser." + :mouse-face 'highlight + :follow-link "\C-m" + "https://github.com/syl20bnr/spacemacs") (insert " ") - (insert-button "[Documentation]" 'action - (lambda (b) (browse-url "https://github.com/syl20bnr/spacemacs/blob/master/doc/DOCUMENTATION.md")) - 'follow-link t 'help-echo "Open the Spacemacs documentation in your browser.") + (widget-create 'url-link + :tag "Documentation" + :help-echo "Open the Spacemacs documentation in your browser." + :mouse-face 'highlight + :follow-link "\C-m" + "https://github.com/syl20bnr/spacemacs/blob/master/doc/DOCUMENTATION.md") (insert " ") - (insert-button "[Gitter Chat]" 'action - (lambda (b) (browse-url "https://gitter.im/syl20bnr/spacemacs")) - 'follow-link t 'help-echo "Ask questions and chat with fellow users in our chat room.") + (widget-create 'url-link + :tag "Gitter Chat" + :help-echo "Ask questions and chat with fellow users in our chat room." + :mouse-face 'highlight + :follow-link "\C-m" + "https://gitter.im/syl20bnr/spacemacs") (insert " ") - (insert-button "[Update]" 'action - (lambda (b) (configuration-layer/update-packages)) - 'follow-link t 'help-echo "Update all ELPA packages to the latest versions.") + (widget-create 'push-button + :help-echo "Update all ELPA packages to the latest versions." + :action (lambda (&rest ignore) (configuration-layer/update-packages)) + :mouse-face 'highlight + :follow-link "\C-m" + "Update") (insert " ") - (insert-button "[Rollback]" 'action - (lambda (b) (call-interactively 'configuration-layer/rollback)) - 'follow-link t 'help-echo "Rollback ELPA package upgrades if something got borked.") + (widget-create 'push-button + :help-echo "Rollback ELPA package upgrades if something got borked." + :action (lambda (&rest ignore) (call-interactively 'configuration-layer/rollback)) + :mouse-face 'highlight + :follow-link "\C-m" + "Rollback") (insert "\n") - (let ((button-title "[Search in Spacemacs]")) + (let ((button-title "[Toggle Changelog] [Search in Spacemacs]")) ; Compute the correct number of spaces to center the button. (dotimes (i (/ (- spacemacs--banner-length (string-width button-title) 1) 2)) (insert " ")) - (insert-button button-title 'action - (lambda (b) (call-interactively 'helm-spacemacs)) 'follow-link t - 'help-echo "Find Spacemacs package and layer configs using helm-spacemacs.")) + (widget-create 'push-button + :help-echo "Hide or show the Changelog" + :action (lambda (&rest ignore) (spacemacs/toggle-changelog)) + :mouse-face 'highlight + :follow-link "\C-m" + "Toggle Changelog")) + (widget-insert " ") + (widget-create 'url-link + :help-echo "Find Spacemacs package and layer configs using helm-spacemacs." + :action (lambda (&rest ignore) (call-interactively 'helm-spacemacs)) + :mouse-face 'highlight + :follow-link "\C-m" + "Search in Spacemacs") (insert "\n\n") ) -(defun spacemacs//insert-file-list (list-display-name list) +(defun spacemacs//insert-file-list (list-display-name list shortcut-char) (when (car list) - (insert list-display-name) + (define-key spacemacs-mode-map shortcut-char `(lambda () + (interactive) + (goto-char ,(point)) + (next-line) + (back-to-indentation))) + (insert (concat " " (format "[%s] " shortcut-char) list-display-name)) (mapc (lambda (el) (insert "\n ") - (insert-button el - 'action `(lambda (b) (find-file-existing ,el)) - 'follow-link t)) + (widget-create 'push-button + :action `(lambda (&rest ignore) (find-file-existing ,el)) + :mouse-face 'highlight + :follow-link "\C-m" + :button-prefix "" + :button-suffix "" + :format "%[%t%]" + (abbreviate-file-name el))) list))) (defun spacemacs/insert-startupify-lists () @@ -204,15 +261,15 @@ buffer, right justified." (cond ((eq el 'recents) (recentf-mode) - (when (spacemacs//insert-file-list " Recent Files:" (recentf-elements 5)) + (when (spacemacs//insert-file-list "Recent Files:" (recentf-elements 5) "r") (insert list-separator))) ((eq el 'bookmarks) (helm-mode) - (when (spacemacs//insert-file-list " Bookmarks:" (bookmark-all-names)) + (when (spacemacs//insert-file-list "Bookmarks:" (bookmark-all-names) "b") (insert list-separator))) ((eq el 'projects) (projectile-mode) - (when (spacemacs//insert-file-list " Projects:" (projectile-relevant-known-projects)) + (when (spacemacs//insert-file-list "Projects:" (projectile-relevant-known-projects) "p") (insert list-separator))))) dotspacemacs-startup-lists)))) (defun spacemacs/goto-link-line () @@ -225,4 +282,9 @@ buffer, right justified." (re-search-forward "Homepage") (beginning-of-line)))) +;;this feels like the wrong place to put these +(add-hook 'spacemacs-mode-hook (lambda () + (local-set-key [tab] 'widget-forward) + (local-set-key [S-tab] 'widget-backward))) + (provide 'core-spacemacs-buffer) diff --git a/core/templates/.spacemacs.template b/core/templates/.spacemacs.template index 03bc39cd0d39..27f3a0f652eb 100644 --- a/core/templates/.spacemacs.template +++ b/core/templates/.spacemacs.template @@ -35,6 +35,8 @@ before layers configuration." ;; If the value is nil then no banner is displayed. ;; dotspacemacs-startup-banner 'official dotspacemacs-startup-banner 'official + ;; t if you always want to see the changelog at startup + dotspacemacs-always-show-changelog t ;; List of items to show in the startup buffer. If nil it is disabled. ;; Possible values are: `recents' `bookmarks' `projects'." dotspacemacs-startup-lists '(recents projects)