2015-01-27 03:51:47 +00:00
|
|
|
|
;;; core-spacemacs-buffer.el --- Spacemacs Core File
|
2015-01-26 03:36:07 +00:00
|
|
|
|
;;
|
2016-01-12 02:40:54 +00:00
|
|
|
|
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
|
2015-01-26 03:36:07 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
|
;;
|
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
|
;;
|
|
|
|
|
;;; License: GPLv3
|
2016-04-01 03:44:00 +00:00
|
|
|
|
(defconst spacemacs-buffer-version-info "0.105"
|
|
|
|
|
"Current version used to display addition release information.")
|
|
|
|
|
|
2015-02-04 04:56:52 +00:00
|
|
|
|
(defconst spacemacs-buffer-name "*spacemacs*"
|
|
|
|
|
"The name of the spacemacs buffer.")
|
|
|
|
|
|
2016-04-01 03:44:00 +00:00
|
|
|
|
(defconst spacemacs-buffer-logo-title "[S P A C E M A C S]"
|
|
|
|
|
"The title displayed beneath the logo.")
|
|
|
|
|
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(defconst spacemacs-buffer--banner-length 75
|
2015-03-13 03:55:38 +00:00
|
|
|
|
"Width of a banner.")
|
2015-01-26 03:36:07 +00:00
|
|
|
|
|
2015-04-13 06:17:48 +00:00
|
|
|
|
(defconst spacemacs-buffer--cache-file
|
|
|
|
|
(expand-file-name (concat spacemacs-cache-directory "spacemacs-buffer.el"))
|
|
|
|
|
"Cache file for various persistent data for the spacemacs startup buffer")
|
|
|
|
|
|
|
|
|
|
(defvar spacemacs-buffer--release-note-version nil
|
|
|
|
|
"If nil the release note is displayed. If non nil it contains
|
|
|
|
|
a version number, if the version number is lesser than the current
|
|
|
|
|
version the release note it displayed")
|
|
|
|
|
|
2015-04-15 14:30:25 +00:00
|
|
|
|
(defvar spacemacs-buffer--note-widgets nil
|
2015-04-13 06:17:48 +00:00
|
|
|
|
"List of widgets used to display the release note.")
|
2015-04-04 14:33:04 +00:00
|
|
|
|
|
2015-04-15 14:30:25 +00:00
|
|
|
|
(defvar spacemacs-buffer--previous-insert-type nil
|
|
|
|
|
"Previous type of note inserted.")
|
|
|
|
|
|
2016-04-03 06:51:44 +00:00
|
|
|
|
(defvar spacemacs-buffer--fresh-install
|
|
|
|
|
(not (file-exists-p dotspacemacs-filepath))
|
|
|
|
|
"Non-nil if this Emacs instance if a fresh install.")
|
|
|
|
|
|
2015-10-16 14:08:08 +00:00
|
|
|
|
(defvar spacemacs-buffer-mode-map
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
(define-key map [tab] 'widget-forward)
|
|
|
|
|
(define-key map (kbd "C-i") 'widget-forward)
|
|
|
|
|
(define-key map [backtab] 'widget-backward)
|
|
|
|
|
(define-key map (kbd "RET") 'widget-button-press)
|
|
|
|
|
(define-key map [down-mouse-1] 'widget-button-click)
|
2016-01-10 19:43:51 +00:00
|
|
|
|
(define-key map "q" 'quit-window)
|
2015-10-16 14:08:08 +00:00
|
|
|
|
map)
|
|
|
|
|
"Keymap for spacemacs buffer mode.")
|
|
|
|
|
|
2016-01-07 17:02:47 +00:00
|
|
|
|
(with-eval-after-load 'evil
|
|
|
|
|
(evil-make-overriding-map spacemacs-buffer-mode-map 'motion))
|
|
|
|
|
|
2016-01-09 04:34:34 +00:00
|
|
|
|
(define-derived-mode spacemacs-buffer-mode fundamental-mode "Spacemacs buffer"
|
2015-10-16 14:08:08 +00:00
|
|
|
|
"Spacemacs major mode for startup screen.
|
|
|
|
|
|
|
|
|
|
\\<spacemacs-buffer-mode-map>
|
|
|
|
|
"
|
|
|
|
|
:group 'spacemacs
|
|
|
|
|
:syntax-table nil
|
|
|
|
|
:abbrev-table nil
|
2016-01-09 04:34:34 +00:00
|
|
|
|
(setq buffer-read-only t
|
|
|
|
|
truncate-lines t)
|
2016-04-06 14:05:34 +00:00
|
|
|
|
(when (fboundp 'page-break-lines-mode)
|
|
|
|
|
(page-break-lines-mode))
|
2015-10-16 14:08:08 +00:00
|
|
|
|
;; needed to make tab work correctly in terminal
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(evil-define-key 'motion spacemacs-buffer-mode-map
|
|
|
|
|
(kbd "C-i") 'widget-forward)
|
2015-10-16 14:08:08 +00:00
|
|
|
|
;; motion state since this is a special mode
|
Use evil in holy-mode
Motivation
While disabling Evil in holy-mode makes its implementation shorter and
sounds elegant on the paper, in practice it puts a big burden on the
configuration parts which need to know if Evil is enable or not. This is
a bad separation of concerns and the bunch of fixes that we were forced
to do in the past weeks shows this issue. Those fixes were about
removing the knowledge of the activation of Evil by implementing new
dispatching functions to be used by layers, this is cumbersome and makes
Spacemacs layer configuration more subtle which is not good. There was
additional bad consequences of the removal of Evil state like the
impossibility to use Evil lisp state or iedit states, or we would have
been forced to implement a temporary activation of Evil which is
awkward.
Instead I reintroduce Evil as the central piece of Spacemacs design thus
Evil is now re-enabled in holy-mode. It provides the abstraction we need
to isolate editing styles and be able to grow the Spacemacs
configuration coverage sanely. Layers don't need to check whether the
holy mode is active or not and they don't need to know if Evil is
available (it is always available). We also don't need to write
additional dispatching functions, this is the job of Evil, and I think
it provides everything for this. Ideally configuration layer should be
implemented with only Evil in mind and the holy-mode (and hybrid-mode)
should magically make it work for Emacs style users, for instance we can
freely use `evil-insert-state` anywhere in the code without any guard.
Evil is now even more part of Spacemacs, we can really say that
Spacemacs is Emacs+Evil which is now an indivisible pair. Spacemacs
needed this stable API to continue on the right track.
While these changes should be rather transparent to the user, I'm sorry
for this experimental period, I failed to see all the implications of
such a change, I was just excited about the possibility to make Evil
optional. The reality is that Spacemacs has to embrace it and keep its
strong position on being Emacs+Evil at the core.
Implementation
- insert, motion and normal states are forced to emacs state using an
advice on `evil-insert-state`, `evil-motion-state` and
`evil-normal-state` respectively. These functions can be used freely in
the layer configuration.
- A new general hook `spacemacs-editing-style-hook` allow to hook any
code that need to be configured based on the editing style. Functions
hooked to this hook takes the current style as parameter, this
basically generalize the hook used to setup hjkl navigation bindings.
- ESC has been removed from the emacs state map.
- Revert unneeded changes
- Revert "evil: enter insert-state only from normal-state"
commit bdd702dfbe302206bbc989c7a0832daba087a781.
- Revert "avoid being evil in deft with emacs editing style"
commit f3a16f49ed27cc8cf05f23f93b006d6e04235381.
Additional changes
All editing style packages have been moved to a layer called
`spacemacs-editing-styles`
Notes
I did not have time to attack hybrid mode, I should be able to do it
later.
2016-03-13 23:41:18 +00:00
|
|
|
|
(evil-set-initial-state 'spacemacs-buffer-mode 'motion))
|
2015-10-16 14:08:08 +00:00
|
|
|
|
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(defun spacemacs-buffer/insert-banner-and-buttons ()
|
2015-07-29 19:40:22 +00:00
|
|
|
|
"Choose a banner according to `dotspacemacs-startup-banner'and insert it
|
|
|
|
|
in spacemacs buffer along with quick buttons underneath.
|
2015-03-13 03:55:38 +00:00
|
|
|
|
|
|
|
|
|
Easter egg:
|
|
|
|
|
Doge special text banner can be reachable via `999', `doge' or `random*'.
|
2015-01-26 03:36:07 +00:00
|
|
|
|
`random' ignore special banners whereas `random*' does not."
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(let ((banner (spacemacs-buffer//choose-banner))
|
2015-01-26 03:36:07 +00:00
|
|
|
|
(buffer-read-only nil))
|
2015-07-29 19:40:22 +00:00
|
|
|
|
(progn
|
|
|
|
|
(when banner
|
|
|
|
|
(spacemacs-buffer/message (format "Banner: %s" banner))
|
|
|
|
|
(if (image-type-available-p (intern (file-name-extension banner)))
|
|
|
|
|
(spacemacs-buffer//insert-image-banner banner)
|
|
|
|
|
(insert-file-contents banner))
|
|
|
|
|
(spacemacs-buffer//inject-version))
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(spacemacs-buffer//insert-buttons)
|
2015-03-13 03:55:38 +00:00
|
|
|
|
(spacemacs//redisplay))))
|
2015-01-26 03:36:07 +00:00
|
|
|
|
|
2016-04-03 06:51:44 +00:00
|
|
|
|
(defun spacemacs-buffer/display-info-box ()
|
|
|
|
|
"Display an info box."
|
|
|
|
|
(when (file-exists-p spacemacs-buffer--cache-file)
|
|
|
|
|
(load spacemacs-buffer--cache-file))
|
|
|
|
|
(cond
|
|
|
|
|
(spacemacs-buffer--fresh-install
|
|
|
|
|
;; we assume the user is new to spacemacs and open the quickhelp
|
|
|
|
|
(spacemacs-buffer/toggle-note
|
|
|
|
|
(concat spacemacs-info-directory "quickhelp.txt")
|
|
|
|
|
(spacemacs-buffer//insert-note-p 'quickhelp))
|
|
|
|
|
(setq spacemacs-buffer--release-note-version spacemacs-version)
|
|
|
|
|
(spacemacs/dump-vars-to-file '(spacemacs-buffer--release-note-version)
|
|
|
|
|
spacemacs-buffer--cache-file))
|
|
|
|
|
((or (not spacemacs-buffer--release-note-version)
|
|
|
|
|
(version< spacemacs-buffer--release-note-version
|
|
|
|
|
spacemacs-version))
|
|
|
|
|
;; check the variable ;; spacemacs-buffer--release-note-version
|
|
|
|
|
;; to decide whether ;; we show the release note
|
|
|
|
|
(spacemacs-buffer/toggle-note
|
|
|
|
|
(concat spacemacs-release-notes-directory
|
|
|
|
|
spacemacs-buffer-version-info ".txt") 'release-note)))
|
|
|
|
|
(spacemacs//redisplay))
|
|
|
|
|
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(defun spacemacs-buffer//choose-banner ()
|
2015-03-09 02:09:09 +00:00
|
|
|
|
"Return the full path of a banner based on the dotfile value."
|
2015-09-07 16:52:09 +00:00
|
|
|
|
(when dotspacemacs-startup-banner
|
|
|
|
|
(cond ((eq 'official dotspacemacs-startup-banner)
|
|
|
|
|
(if (and (display-graphic-p) (image-type-available-p 'png))
|
|
|
|
|
spacemacs-banner-official-png
|
|
|
|
|
(spacemacs-buffer//get-banner-path 1)))
|
|
|
|
|
((eq 'random dotspacemacs-startup-banner)
|
|
|
|
|
(spacemacs-buffer//choose-random-text-banner))
|
|
|
|
|
((eq 'random* dotspacemacs-startup-banner)
|
|
|
|
|
(spacemacs-buffer//choose-random-text-banner t))
|
|
|
|
|
((eq 'doge dotspacemacs-startup-banner)
|
|
|
|
|
(spacemacs-buffer//get-banner-path 999))
|
|
|
|
|
((integerp dotspacemacs-startup-banner)
|
|
|
|
|
(spacemacs-buffer//get-banner-path dotspacemacs-startup-banner))
|
|
|
|
|
((and dotspacemacs-startup-banner
|
|
|
|
|
(image-type-available-p (intern (file-name-extension
|
|
|
|
|
dotspacemacs-startup-banner)))
|
|
|
|
|
(display-graphic-p))
|
|
|
|
|
(if (file-exists-p dotspacemacs-startup-banner)
|
|
|
|
|
dotspacemacs-startup-banner
|
|
|
|
|
(spacemacs-buffer/warning (format "could not find banner %s"
|
|
|
|
|
dotspacemacs-startup-banner))
|
|
|
|
|
(spacemacs-buffer//get-banner-path 1)))
|
|
|
|
|
(t (spacemacs-buffer//get-banner-path 1)))))
|
2015-03-09 02:09:09 +00:00
|
|
|
|
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(defun spacemacs-buffer//choose-random-text-banner (&optional all)
|
2015-01-26 03:36:07 +00:00
|
|
|
|
"Return the full path of a banner chosen randomly.
|
|
|
|
|
|
|
|
|
|
If ALL is non-nil then truly all banners can be selected."
|
|
|
|
|
(let* ((files (directory-files spacemacs-banner-directory t))
|
|
|
|
|
(count (length files))
|
|
|
|
|
;; -2 then +2 to remove `.' and `..'
|
|
|
|
|
(choice (+ 2 (random (- count (if all 2 3))))))
|
|
|
|
|
(nth choice files)))
|
|
|
|
|
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(defun spacemacs-buffer//get-banner-path (index)
|
2015-01-26 03:36:07 +00:00
|
|
|
|
"Return the full path to banner with index INDEX."
|
|
|
|
|
(concat spacemacs-banner-directory (format "%03d-banner.txt" index)))
|
|
|
|
|
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(defun spacemacs-buffer//insert-image-banner (banner)
|
2015-03-13 03:55:38 +00:00
|
|
|
|
"Display an image banner."
|
|
|
|
|
(when (file-exists-p banner)
|
2016-04-01 03:44:00 +00:00
|
|
|
|
(let* ((title spacemacs-buffer-logo-title)
|
2015-07-30 02:07:27 +00:00
|
|
|
|
(spec (create-image banner))
|
2015-03-13 03:55:38 +00:00
|
|
|
|
(size (image-size spec))
|
|
|
|
|
(width (car size))
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(left-margin (floor (- spacemacs-buffer--banner-length width) 2)))
|
2015-12-16 14:45:08 +00:00
|
|
|
|
(goto-char (point-min))
|
2015-03-13 03:55:38 +00:00
|
|
|
|
(insert "\n")
|
2016-04-01 03:44:00 +00:00
|
|
|
|
(insert (make-string left-margin ?\ ))
|
2015-03-13 03:55:38 +00:00
|
|
|
|
(insert-image spec)
|
|
|
|
|
(insert "\n\n")
|
2016-04-01 03:44:00 +00:00
|
|
|
|
(insert (make-string (floor (/ (- spacemacs-buffer--banner-length
|
|
|
|
|
(+ (length title) 1)) 2)) ?\ ))
|
2015-07-30 02:07:27 +00:00
|
|
|
|
(insert (format "%s\n\n" title)))))
|
2015-03-13 03:55:38 +00:00
|
|
|
|
|
2015-09-12 03:14:16 +00:00
|
|
|
|
(defun spacemacs-buffer//inject-version (&optional insert-distro)
|
2015-01-26 03:36:07 +00:00
|
|
|
|
"Inject the current version of spacemacs in the first line of the
|
|
|
|
|
buffer, right justified."
|
2016-04-01 03:44:00 +00:00
|
|
|
|
(with-current-buffer (get-buffer-create spacemacs-buffer-name)
|
2015-09-12 03:04:01 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ((maxcol spacemacs-buffer--banner-length)
|
2015-10-30 23:09:26 +00:00
|
|
|
|
(lhs (format "(emacs-%s)" emacs-version))
|
|
|
|
|
(rhs (if insert-distro
|
2015-09-12 03:14:16 +00:00
|
|
|
|
(format "(%s-%s)"
|
|
|
|
|
dotspacemacs-distribution
|
|
|
|
|
spacemacs-version)
|
|
|
|
|
(format "(%s)" spacemacs-version)))
|
2015-10-30 23:09:26 +00:00
|
|
|
|
(len (- maxcol (length lhs)))
|
2015-09-12 03:04:01 +00:00
|
|
|
|
(buffer-read-only nil))
|
2015-10-30 23:09:26 +00:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(delete-region (point) (progn (end-of-line) (point)))
|
|
|
|
|
(insert (format
|
|
|
|
|
(format "%%s %%%ds" len)
|
|
|
|
|
lhs rhs))))))
|
2015-01-26 03:36:07 +00:00
|
|
|
|
|
2015-04-15 14:30:25 +00:00
|
|
|
|
(defun spacemacs-buffer//insert-note (file caption &optional additional-widgets)
|
|
|
|
|
"Insert the release note just under the banner.
|
|
|
|
|
|
|
|
|
|
FILE is the file that contains the content to show.
|
|
|
|
|
CAPTION is the title of the note.
|
|
|
|
|
TAG-STRING is the label of the button for additional action.
|
|
|
|
|
HELP-STRING is the help message of the button for additional action."
|
2015-04-04 14:33:04 +00:00
|
|
|
|
(save-excursion
|
2015-12-16 14:45:08 +00:00
|
|
|
|
(goto-char (point-min))
|
2015-10-15 16:38:28 +00:00
|
|
|
|
(search-forward "Search in Spacemacs\]")
|
2015-12-16 14:45:08 +00:00
|
|
|
|
(forward-line)
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(let* ((note (concat "\n" (spacemacs//render-framed-text
|
|
|
|
|
file spacemacs-buffer--banner-length caption))))
|
2015-04-15 14:30:25 +00:00
|
|
|
|
(add-to-list 'spacemacs-buffer--note-widgets (widget-create 'text note))
|
|
|
|
|
(funcall additional-widgets))))
|
|
|
|
|
|
|
|
|
|
(defun spacemacs-buffer//insert-note-p (type)
|
|
|
|
|
"Decicde if whether to insert note widget or not based on current note TYPE.
|
|
|
|
|
|
|
|
|
|
If note TYPE is `quickhelp' or `release-note' and is equal to
|
|
|
|
|
previous insert type in `spacemacs-buffer--previous-insert-type',
|
|
|
|
|
which means previous note widget of the same type already
|
|
|
|
|
inserted. In this case, we simply delete the widgets but don't insert.
|
|
|
|
|
|
|
|
|
|
Otherwise, delete and allow insert note of TYPE."
|
|
|
|
|
(if (not (eq spacemacs-buffer--previous-insert-type type))
|
|
|
|
|
type
|
|
|
|
|
(setq spacemacs-buffer--previous-insert-type nil)))
|
|
|
|
|
|
|
|
|
|
(defun spacemacs-buffer/toggle-note (file type)
|
|
|
|
|
"Toggle the note in FILE for the buffer based on TYPE.
|
|
|
|
|
|
|
|
|
|
If TYPE is nil, just remove widgets."
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(interactive)
|
2015-04-15 14:30:25 +00:00
|
|
|
|
(spacemacs-buffer//remove-existing-widget-if-exist)
|
|
|
|
|
(cond
|
|
|
|
|
((eq type 'quickhelp)
|
|
|
|
|
(spacemacs-buffer//insert-quickhelp-widget file))
|
|
|
|
|
((eq type 'release-note)
|
|
|
|
|
(spacemacs-buffer//insert-release-note-widget file))
|
2015-04-19 06:11:04 +00:00
|
|
|
|
(t)))
|
2015-04-15 14:30:25 +00:00
|
|
|
|
|
|
|
|
|
(defun spacemacs-buffer//remove-existing-widget-if-exist ()
|
|
|
|
|
"Remove existing note widgets if exists."
|
|
|
|
|
(when spacemacs-buffer--note-widgets
|
|
|
|
|
(spacemacs-buffer//remove-note-widgets)))
|
|
|
|
|
|
|
|
|
|
(defun spacemacs-buffer//insert-quickhelp-widget (file)
|
|
|
|
|
"Insert quickhelp with content from FILE."
|
|
|
|
|
(spacemacs-buffer//remove-existing-widget-if-exist)
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(let ((widget-func
|
|
|
|
|
(lambda ()
|
|
|
|
|
(add-to-list
|
|
|
|
|
'spacemacs-buffer--note-widgets
|
|
|
|
|
(widget-create 'push-button
|
|
|
|
|
:tag (propertize "Evil Tutorial"
|
|
|
|
|
'face 'font-lock-keyword-face)
|
|
|
|
|
:help-echo
|
|
|
|
|
"Teach you how to use Vim basics."
|
|
|
|
|
:action (lambda (&rest ignore)
|
|
|
|
|
(call-interactively #'evil-tutor-start))
|
|
|
|
|
:mouse-face 'highlight
|
|
|
|
|
:follow-link "\C-m"))
|
|
|
|
|
(widget-insert " ")
|
|
|
|
|
(add-to-list
|
|
|
|
|
'spacemacs-buffer--note-widgets
|
|
|
|
|
(widget-create 'push-button
|
|
|
|
|
:tag (propertize "Emacs Tutorial"
|
|
|
|
|
'face 'font-lock-keyword-face)
|
|
|
|
|
:help-echo "Teach you how to use Emacs basics."
|
|
|
|
|
:action (lambda (&rest ignore)
|
|
|
|
|
(call-interactively #'help-with-tutorial))
|
|
|
|
|
:mouse-face 'highlight
|
|
|
|
|
:follow-link "\C-m"))
|
|
|
|
|
(widget-insert " ")
|
|
|
|
|
(add-to-list
|
|
|
|
|
'spacemacs-buffer--note-widgets
|
|
|
|
|
(widget-create 'push-button
|
|
|
|
|
:tag (propertize "Vim Migration Guide"
|
|
|
|
|
'face 'font-lock-keyword-face)
|
|
|
|
|
:help-echo "Documentation for former vim users."
|
|
|
|
|
:action (lambda (&rest ignore)
|
|
|
|
|
(spacemacs/view-org-file
|
|
|
|
|
(concat spacemacs-docs-directory
|
|
|
|
|
"VIMUSERS.org") "^" 'all))
|
|
|
|
|
:mouse-face 'highlight
|
|
|
|
|
:follow-link "\C-m")))))
|
2015-04-15 14:30:25 +00:00
|
|
|
|
(spacemacs-buffer//insert-note file "Quick Help" widget-func))
|
|
|
|
|
(setq spacemacs-buffer--previous-insert-type 'quickhelp))
|
|
|
|
|
|
|
|
|
|
(defun spacemacs-buffer//insert-release-note-widget (file)
|
|
|
|
|
"Insert release note with content from FILE."
|
|
|
|
|
(spacemacs-buffer//remove-existing-widget-if-exist)
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(let ((widget-func
|
|
|
|
|
(lambda ()
|
|
|
|
|
(add-to-list
|
|
|
|
|
'spacemacs-buffer--note-widgets
|
|
|
|
|
(widget-create 'push-button
|
|
|
|
|
:tag (propertize "Click here for full change log"
|
|
|
|
|
'face 'font-lock-warning-face)
|
|
|
|
|
:help-echo "Open the full change log."
|
2016-04-01 03:44:00 +00:00
|
|
|
|
:action
|
|
|
|
|
(lambda (&rest ignore)
|
|
|
|
|
(funcall 'spacemacs/view-org-file
|
|
|
|
|
(concat user-emacs-directory
|
|
|
|
|
"CHANGELOG.org")
|
|
|
|
|
(format "Release %s.x"
|
|
|
|
|
spacemacs-buffer-version-info)
|
|
|
|
|
'subtree))
|
2016-02-01 01:24:13 +00:00
|
|
|
|
:mouse-face 'highlight
|
|
|
|
|
:follow-link "\C-m")))))
|
2015-04-15 14:30:25 +00:00
|
|
|
|
(spacemacs-buffer//insert-note file
|
2016-04-01 03:44:00 +00:00
|
|
|
|
(format " Important Notes (Release %s.x) "
|
|
|
|
|
spacemacs-buffer-version-info)
|
2015-04-15 14:30:25 +00:00
|
|
|
|
widget-func))
|
|
|
|
|
|
|
|
|
|
(setq spacemacs-buffer--release-note-version nil)
|
|
|
|
|
(spacemacs/dump-vars-to-file
|
|
|
|
|
'(spacemacs-buffer--release-note-version) spacemacs-buffer--cache-file)
|
|
|
|
|
(setq spacemacs-buffer--previous-insert-type 'release-note))
|
|
|
|
|
|
|
|
|
|
(defun spacemacs-buffer//remove-note-widgets ()
|
|
|
|
|
(mapc 'widget-delete spacemacs-buffer--note-widgets)
|
|
|
|
|
(setq spacemacs-buffer--note-widgets nil)
|
|
|
|
|
(setq spacemacs-buffer--release-note-version spacemacs-version)
|
|
|
|
|
(spacemacs/dump-vars-to-file
|
|
|
|
|
'(spacemacs-buffer--release-note-version) spacemacs-buffer--cache-file))
|
2015-04-04 14:33:04 +00:00
|
|
|
|
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(defun spacemacs-buffer/set-mode-line (format)
|
2015-03-16 05:28:21 +00:00
|
|
|
|
"Set mode-line format for spacemacs buffer."
|
2016-04-01 03:44:00 +00:00
|
|
|
|
(with-current-buffer (get-buffer-create spacemacs-buffer-name)
|
2015-03-16 05:28:21 +00:00
|
|
|
|
(setq mode-line-format format)))
|
|
|
|
|
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(defun spacemacs-buffer/message (msg &rest args)
|
2015-04-12 16:25:53 +00:00
|
|
|
|
"Display MSG in message prepended with '(Spacemacs)'.
|
2015-10-07 19:29:20 +00:00
|
|
|
|
The message is displayed only if `init-file-debug' is non nil."
|
|
|
|
|
(when init-file-debug
|
2015-04-06 03:45:02 +00:00
|
|
|
|
(message "(Spacemacs) %s" (apply 'format msg args))))
|
2015-01-26 03:36:07 +00:00
|
|
|
|
|
2015-04-12 16:25:53 +00:00
|
|
|
|
(defun spacemacs-buffer/warning (msg &rest args)
|
|
|
|
|
"Display MSG as a warning message but in buffer `*Messages*'.
|
|
|
|
|
The message is always displayed. "
|
|
|
|
|
(message "(Spacemacs) Warning: %s" (apply 'format msg args)))
|
|
|
|
|
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(defun spacemacs-buffer/insert-page-break ()
|
2015-04-03 02:23:16 +00:00
|
|
|
|
"Insert a page break line in spacemacs buffer."
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(spacemacs-buffer/append "\n\n\n"))
|
2015-04-03 02:23:16 +00:00
|
|
|
|
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(defun spacemacs-buffer/append (msg &optional messagebuf)
|
2015-01-26 03:36:07 +00:00
|
|
|
|
"Append MSG to spacemacs buffer. If MESSAGEBUF is not nil then MSG is
|
|
|
|
|
also written in message buffer."
|
2016-04-01 03:44:00 +00:00
|
|
|
|
(with-current-buffer (get-buffer-create spacemacs-buffer-name)
|
2015-01-26 03:36:07 +00:00
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(let ((buffer-read-only nil))
|
|
|
|
|
(insert msg)
|
2015-03-12 04:25:52 +00:00
|
|
|
|
(if messagebuf (message "(Spacemacs) %s" msg)))
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(spacemacs-buffer/set-mode-line "")))
|
2015-01-26 03:36:07 +00:00
|
|
|
|
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(defun spacemacs-buffer/replace-last-line (msg &optional messagebuf)
|
2015-01-26 03:36:07 +00:00
|
|
|
|
"Replace the last line of the spacemacs buffer with MSG. If MESSAGEBUF is
|
|
|
|
|
not nil then MSG is also written in message buffer."
|
2016-04-01 03:44:00 +00:00
|
|
|
|
(with-current-buffer (get-buffer-create spacemacs-buffer-name)
|
2015-01-26 03:36:07 +00:00
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(let ((buffer-read-only nil))
|
|
|
|
|
(delete-region (line-beginning-position) (point-max))
|
|
|
|
|
(insert msg)
|
2015-03-12 04:25:52 +00:00
|
|
|
|
(if messagebuf (message "(Spacemacs) %s" msg)))
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(spacemacs-buffer/set-mode-line "")))
|
2015-01-26 03:36:07 +00:00
|
|
|
|
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(defun spacemacs-buffer/insert-framed-text
|
2015-04-06 00:59:55 +00:00
|
|
|
|
(msg &optional caption hpadding)
|
|
|
|
|
"Insert MSG in spacemacs buffer within a frame of width FILL-COLUMN.
|
|
|
|
|
|
|
|
|
|
See `spacemacs//render-framed-text' for documentation of the other
|
|
|
|
|
parameters."
|
2016-04-01 03:44:00 +00:00
|
|
|
|
(with-current-buffer (get-buffer-create spacemacs-buffer-name)
|
2015-04-06 00:59:55 +00:00
|
|
|
|
(let ((buffer-read-only nil))
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(insert (spacemacs//render-framed-text msg spacemacs-buffer--banner-length
|
2015-04-06 00:59:55 +00:00
|
|
|
|
caption hpadding)))))
|
|
|
|
|
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(defun spacemacs-buffer/insert-framed-text-from-file
|
2015-04-06 00:59:55 +00:00
|
|
|
|
(filepath &optional caption hpadding)
|
|
|
|
|
"Insert at point the content of FILENAME file in spacemacs buffer in a
|
|
|
|
|
frame.
|
|
|
|
|
|
|
|
|
|
If FILEPATH does not exists the function returns nil.
|
|
|
|
|
|
|
|
|
|
See `spacemacs//render-framed-text' for documentation of the other
|
|
|
|
|
parameters."
|
|
|
|
|
(when (file-exists-p filepath)
|
2016-04-01 03:44:00 +00:00
|
|
|
|
(with-current-buffer (get-buffer-create spacemacs-buffer-name)
|
2015-04-06 00:59:55 +00:00
|
|
|
|
(let ((buffer-read-only nil))
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(insert (spacemacs//render-framed-text
|
|
|
|
|
filepath spacemacs-buffer--banner-length caption hpadding))))))
|
2015-04-06 00:59:55 +00:00
|
|
|
|
|
|
|
|
|
(defun spacemacs//render-framed-text (content &optional width caption hpadding)
|
|
|
|
|
"Return a formated string framed with plained lines of width FILL-COLUMN.
|
|
|
|
|
|
|
|
|
|
CONTENT can be a text or a filepath.
|
|
|
|
|
|
|
|
|
|
WIDTH set the `fill-column' variable.
|
|
|
|
|
|
|
|
|
|
If CAPTION is non nil string then it is included in at the top of the frame.
|
|
|
|
|
If CAPTION length is greater than FILL-COLUMN minus 5 the function returns
|
|
|
|
|
nil.
|
|
|
|
|
|
|
|
|
|
HPADDING is the horizontal spacing between the text and the frame.
|
|
|
|
|
The vertical spacing is always one line."
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(if (not (file-exists-p content))
|
|
|
|
|
(insert content)
|
|
|
|
|
(insert-file-contents content)
|
|
|
|
|
;; remove additional newline at eof
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(delete-char -1))
|
|
|
|
|
(let* ((hpadding (or hpadding 1))
|
|
|
|
|
(fill-column (if width
|
2015-07-30 02:07:27 +00:00
|
|
|
|
(- width (+ 2 (* 2 hpadding)))
|
2015-04-06 00:59:55 +00:00
|
|
|
|
fill-column))
|
|
|
|
|
(sentence-end-double-space nil)
|
|
|
|
|
(caption-len (length caption)))
|
2015-04-19 04:26:24 +00:00
|
|
|
|
(fill-region (point-min) (point-max) 'justify 'nosqueeze)
|
2015-04-06 00:59:55 +00:00
|
|
|
|
(concat
|
|
|
|
|
;; top
|
|
|
|
|
"╭─"
|
|
|
|
|
(if caption
|
|
|
|
|
(concat caption
|
|
|
|
|
(make-string (+ (- fill-column caption-len 1)
|
|
|
|
|
hpadding) ?─))
|
|
|
|
|
(make-string fill-column ?─))
|
|
|
|
|
(make-string hpadding ?─) "╮\n"
|
|
|
|
|
;; content
|
|
|
|
|
(spacemacs//render-framed-line "" hpadding)
|
|
|
|
|
(mapconcat (lambda (x)
|
|
|
|
|
(spacemacs//render-framed-line x hpadding))
|
|
|
|
|
(split-string (buffer-string) "\n" nil) "")
|
|
|
|
|
(spacemacs//render-framed-line "" hpadding)
|
|
|
|
|
;; bottom
|
|
|
|
|
"╰" (make-string hpadding ?─)
|
|
|
|
|
(make-string fill-column ?─)
|
2015-04-13 06:17:48 +00:00
|
|
|
|
(make-string hpadding ?─) "╯"))))
|
2015-04-06 00:59:55 +00:00
|
|
|
|
|
|
|
|
|
(defun spacemacs//render-framed-line (line hpadding)
|
|
|
|
|
"Return a formated LINE with borders of a frame on each side and
|
|
|
|
|
with width FILL-COLUMN.
|
|
|
|
|
|
|
|
|
|
If length of LINE is bigger than FILL-COLUMN it returns nil.
|
|
|
|
|
|
2016-02-01 01:24:13 +00:00
|
|
|
|
HPADDING is the horizontal spacing betwee the content line and the frame
|
|
|
|
|
border."
|
2015-04-06 00:59:55 +00:00
|
|
|
|
(let* ((len (length line))
|
|
|
|
|
(fill (- fill-column len)))
|
|
|
|
|
(when (>= fill 0)
|
|
|
|
|
(concat "│" (make-string hpadding ?\s)
|
|
|
|
|
line (make-string fill ?\s)
|
|
|
|
|
(make-string hpadding ?\s) "│\n"))))
|
|
|
|
|
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(defun spacemacs-buffer/loading-animation ()
|
2016-02-01 01:24:13 +00:00
|
|
|
|
"Display the progress bar by chunk of size
|
|
|
|
|
`spacemacs--loading-dots-chunk-threshold'."
|
2015-02-16 02:25:12 +00:00
|
|
|
|
(when dotspacemacs-loading-progress-bar
|
|
|
|
|
(setq spacemacs-loading-counter (1+ spacemacs-loading-counter))
|
|
|
|
|
(when (>= spacemacs-loading-counter spacemacs-loading-dots-chunk-threshold)
|
|
|
|
|
(setq spacemacs-loading-counter 0)
|
2015-03-12 03:46:37 +00:00
|
|
|
|
(setq spacemacs-loading-string
|
|
|
|
|
(concat spacemacs-loading-string
|
|
|
|
|
(make-string spacemacs-loading-dots-chunk-size
|
|
|
|
|
spacemacs-loading-char)))
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(spacemacs-buffer/set-mode-line spacemacs-loading-string)
|
2015-02-16 02:25:12 +00:00
|
|
|
|
(spacemacs//redisplay))))
|
2015-01-26 03:36:07 +00:00
|
|
|
|
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(defmacro spacemacs//insert--shortcut (shortcut-char search-label
|
|
|
|
|
&optional no-next-line)
|
|
|
|
|
`(define-key spacemacs-buffer-mode-map
|
|
|
|
|
,shortcut-char (lambda ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(unless (search-forward ,search-label (point-max) t)
|
|
|
|
|
(search-backward ,search-label (point-min) t))
|
|
|
|
|
,@(unless no-next-line
|
|
|
|
|
'((forward-line 1)))
|
|
|
|
|
(back-to-indentation))))
|
2015-04-20 20:01:11 +00:00
|
|
|
|
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(defun spacemacs-buffer//insert-buttons ()
|
2015-01-26 03:36:07 +00:00
|
|
|
|
(goto-char (point-max))
|
2015-07-30 02:07:27 +00:00
|
|
|
|
(insert " ")
|
2015-04-20 20:01:11 +00:00
|
|
|
|
(spacemacs//insert--shortcut "m" "[?]" t)
|
2015-04-15 14:30:25 +00:00
|
|
|
|
(widget-create 'url-link
|
|
|
|
|
:tag (propertize "?" 'face 'font-lock-doc-face)
|
|
|
|
|
:help-echo "Open the quickhelp."
|
|
|
|
|
:action (lambda (&rest ignore)
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(spacemacs-buffer/toggle-note
|
|
|
|
|
(concat spacemacs-info-directory "quickhelp.txt")
|
|
|
|
|
;; if nil is returned,
|
|
|
|
|
;; just delete the current note widgets
|
|
|
|
|
(spacemacs-buffer//insert-note-p 'quickhelp)))
|
2015-04-15 14:30:25 +00:00
|
|
|
|
:mouse-face 'highlight
|
|
|
|
|
:follow-link "\C-m"
|
|
|
|
|
)
|
2015-04-19 06:11:04 +00:00
|
|
|
|
(insert " ")
|
2015-04-02 14:23:36 +00:00
|
|
|
|
(widget-create 'url-link
|
2015-04-13 05:46:39 +00:00
|
|
|
|
:tag (propertize "Homepage" 'face 'font-lock-keyword-face)
|
2015-04-02 14:23:36 +00:00
|
|
|
|
:help-echo "Open the Spacemacs Github page in your browser."
|
|
|
|
|
:mouse-face 'highlight
|
|
|
|
|
:follow-link "\C-m"
|
2016-01-06 06:21:06 +00:00
|
|
|
|
"http://spacemacs.org")
|
2015-01-26 03:36:07 +00:00
|
|
|
|
(insert " ")
|
2015-04-02 14:23:36 +00:00
|
|
|
|
(widget-create 'url-link
|
2015-04-13 05:46:39 +00:00
|
|
|
|
:tag (propertize "Documentation" 'face 'font-lock-keyword-face)
|
2015-04-02 14:23:36 +00:00
|
|
|
|
:help-echo "Open the Spacemacs documentation in your browser."
|
|
|
|
|
:mouse-face 'highlight
|
|
|
|
|
:follow-link "\C-m"
|
2016-01-06 06:21:06 +00:00
|
|
|
|
"http://spacemacs.org/doc/DOCUMENTATION.html")
|
2015-01-26 03:36:07 +00:00
|
|
|
|
(insert " ")
|
2015-04-02 14:23:36 +00:00
|
|
|
|
(widget-create 'url-link
|
2015-04-13 05:46:39 +00:00
|
|
|
|
:tag (propertize "Gitter Chat" 'face 'font-lock-keyword-face)
|
2016-02-01 01:24:13 +00:00
|
|
|
|
:help-echo
|
|
|
|
|
"Ask questions and chat with fellow users in our chat room."
|
2015-04-02 14:23:36 +00:00
|
|
|
|
:mouse-face 'highlight
|
|
|
|
|
:follow-link "\C-m"
|
|
|
|
|
"https://gitter.im/syl20bnr/spacemacs")
|
2015-01-26 03:36:07 +00:00
|
|
|
|
(insert " ")
|
2015-10-12 21:00:59 +00:00
|
|
|
|
(widget-create 'push-button
|
|
|
|
|
:help-echo "Update Spacemacs core and layers."
|
|
|
|
|
:action (lambda (&rest ignore) (spacemacs/switch-to-version))
|
|
|
|
|
:mouse-face 'highlight
|
|
|
|
|
:follow-link "\C-m"
|
|
|
|
|
(propertize "Update Spacemacs" 'face 'font-lock-keyword-face))
|
|
|
|
|
(insert "\n ")
|
2015-04-02 14:23:36 +00:00
|
|
|
|
(widget-create 'push-button
|
|
|
|
|
:help-echo "Update all ELPA packages to the latest versions."
|
2016-02-01 01:24:13 +00:00
|
|
|
|
:action (lambda (&rest ignore)
|
|
|
|
|
(configuration-layer/update-packages))
|
2015-04-02 14:23:36 +00:00
|
|
|
|
:mouse-face 'highlight
|
|
|
|
|
:follow-link "\C-m"
|
2015-10-12 21:00:59 +00:00
|
|
|
|
(propertize "Update Packages" 'face 'font-lock-keyword-face))
|
2015-01-26 03:36:07 +00:00
|
|
|
|
(insert " ")
|
2015-04-02 14:23:36 +00:00
|
|
|
|
(widget-create 'push-button
|
2016-02-01 01:24:13 +00:00
|
|
|
|
:help-echo
|
|
|
|
|
"Rollback ELPA package updates if something got borked."
|
|
|
|
|
:action (lambda (&rest ignore)
|
|
|
|
|
(call-interactively 'configuration-layer/rollback))
|
2015-04-02 14:23:36 +00:00
|
|
|
|
:mouse-face 'highlight
|
|
|
|
|
:follow-link "\C-m"
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(propertize "Rollback Package Update"
|
|
|
|
|
'face 'font-lock-keyword-face))
|
2015-03-02 00:53:45 +00:00
|
|
|
|
(insert "\n")
|
2015-07-30 02:07:27 +00:00
|
|
|
|
(insert " ")
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(widget-create 'push-button
|
2016-02-01 01:24:13 +00:00
|
|
|
|
:tag (propertize "Release Notes"
|
|
|
|
|
'face 'font-lock-preprocessor-face)
|
2015-04-12 04:24:03 +00:00
|
|
|
|
:help-echo "Hide or show the Changelog"
|
2015-04-15 14:30:25 +00:00
|
|
|
|
:action (lambda (&rest ignore)
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(spacemacs-buffer/toggle-note
|
|
|
|
|
(concat spacemacs-release-notes-directory
|
2016-04-01 03:44:00 +00:00
|
|
|
|
spacemacs-buffer-version-info
|
|
|
|
|
".txt")
|
2016-02-01 01:24:13 +00:00
|
|
|
|
;; if nil is returned,
|
|
|
|
|
;; just delete the current note widgets
|
|
|
|
|
(spacemacs-buffer//insert-note-p 'release-note)))
|
2015-04-12 04:24:03 +00:00
|
|
|
|
:mouse-face 'highlight
|
|
|
|
|
:follow-link "\C-m"
|
|
|
|
|
)
|
|
|
|
|
(insert " ")
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(widget-create 'url-link
|
|
|
|
|
:tag (propertize "Search in Spacemacs"
|
|
|
|
|
'face 'font-lock-function-name-face)
|
|
|
|
|
:help-echo "Search Spacemacs contents."
|
|
|
|
|
:action
|
|
|
|
|
(lambda (&rest ignore)
|
|
|
|
|
(let ((comp-frontend
|
|
|
|
|
(cond
|
|
|
|
|
((configuration-layer/layer-usedp 'spacemacs-helm)
|
|
|
|
|
'helm-spacemacs-help)
|
|
|
|
|
((configuration-layer/layer-usedp 'spacemacs-ivy)
|
|
|
|
|
'ivy-spacemacs-help))))
|
|
|
|
|
(call-interactively comp-frontend)))
|
|
|
|
|
:mouse-face 'highlight
|
|
|
|
|
:follow-link "\C-m")
|
2015-04-06 00:59:55 +00:00
|
|
|
|
(insert "\n\n"))
|
2015-01-26 03:36:07 +00:00
|
|
|
|
|
2015-06-03 06:45:54 +00:00
|
|
|
|
(defun spacemacs-buffer//insert-file-list (list-display-name list)
|
2015-03-28 14:30:56 +00:00
|
|
|
|
(when (car list)
|
2015-04-13 14:18:19 +00:00
|
|
|
|
(insert list-display-name)
|
2015-03-28 14:30:56 +00:00
|
|
|
|
(mapc (lambda (el)
|
|
|
|
|
(insert "\n ")
|
2015-04-02 14:23:36 +00:00
|
|
|
|
(widget-create 'push-button
|
2016-02-01 01:24:13 +00:00
|
|
|
|
:action `(lambda (&rest ignore)
|
|
|
|
|
(find-file-existing ,el))
|
2015-04-02 14:23:36 +00:00
|
|
|
|
:mouse-face 'highlight
|
|
|
|
|
:follow-link "\C-m"
|
|
|
|
|
:button-prefix ""
|
|
|
|
|
:button-suffix ""
|
|
|
|
|
:format "%[%t%]"
|
|
|
|
|
(abbreviate-file-name el)))
|
2015-03-28 14:30:56 +00:00
|
|
|
|
list)))
|
|
|
|
|
|
2015-07-30 02:21:31 +00:00
|
|
|
|
(defun spacemacs-buffer//insert-bookmark-list (list-display-name list)
|
|
|
|
|
(when (car list)
|
|
|
|
|
(insert list-display-name)
|
|
|
|
|
(mapc (lambda (el)
|
|
|
|
|
(insert "\n ")
|
2016-02-14 16:09:16 +00:00
|
|
|
|
(let ((filename (bookmark-get-filename el)))
|
|
|
|
|
(widget-create 'push-button
|
|
|
|
|
:action `(lambda (&rest ignore) (bookmark-jump ,el))
|
|
|
|
|
:mouse-face 'highlight
|
|
|
|
|
:follow-link "\C-m"
|
|
|
|
|
:button-prefix ""
|
|
|
|
|
:button-suffix ""
|
|
|
|
|
:format "%[%t%]"
|
|
|
|
|
(if filename
|
|
|
|
|
(format "%s - %s"
|
|
|
|
|
el (abbreviate-file-name filename))
|
|
|
|
|
(format "%s" el)))))
|
2015-07-30 02:21:31 +00:00
|
|
|
|
list)))
|
|
|
|
|
|
2016-01-07 22:07:28 +00:00
|
|
|
|
(defun spacemacs-buffer//get-org-items (types)
|
|
|
|
|
"Make a list of agenda file items for today of kind types"
|
|
|
|
|
(require 'org-agenda)
|
|
|
|
|
(let ((date (calendar-gregorian-from-absolute (org-today))))
|
|
|
|
|
(apply #'append
|
|
|
|
|
(loop for file in (org-agenda-files nil 'ifmode)
|
|
|
|
|
collect
|
|
|
|
|
(spacemacs-buffer//make-org-items
|
|
|
|
|
file
|
|
|
|
|
(apply 'org-agenda-get-day-entries file date
|
|
|
|
|
types))))))
|
|
|
|
|
|
|
|
|
|
(defun spacemacs-buffer//agenda-list ()
|
|
|
|
|
"Returns today's agenda"
|
|
|
|
|
(require 'org-agenda)
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(spacemacs-buffer//get-org-items org-agenda-entry-types))
|
2016-01-07 22:07:28 +00:00
|
|
|
|
|
|
|
|
|
(defun spacemacs-buffer//todo-list ()
|
|
|
|
|
"Returns current todos"
|
|
|
|
|
(require 'org-agenda)
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(spacemacs-buffer//get-org-items '(:todo)))
|
2016-01-07 22:07:28 +00:00
|
|
|
|
|
|
|
|
|
(defun spacemacs-buffer//make-org-items (file items)
|
|
|
|
|
"make a spacemacs-buffer org item list"
|
|
|
|
|
(loop
|
|
|
|
|
for item in items
|
|
|
|
|
collect
|
|
|
|
|
(spacemacs-buffer//make-org-item file item)))
|
|
|
|
|
|
|
|
|
|
(defun spacemacs-buffer//make-org-item (file item)
|
|
|
|
|
"make a spacemacs-buffer version of an org item"
|
|
|
|
|
(list (cons "text"
|
|
|
|
|
(get-text-property 0 'txt item))
|
|
|
|
|
(cons "file" file)
|
|
|
|
|
(cons "pos"
|
|
|
|
|
(marker-position
|
|
|
|
|
(get-text-property 0 'org-marker item)))
|
|
|
|
|
(cons "time"
|
|
|
|
|
(get-text-property 0 'time item))))
|
|
|
|
|
|
|
|
|
|
(defun spacemacs-buffer//org-jump (el)
|
|
|
|
|
(require 'org-agenda)
|
|
|
|
|
(find-file-other-window (cdr (assoc "file" el)))
|
|
|
|
|
(widen)
|
|
|
|
|
(goto-char (cdr (assoc "pos" el)))
|
|
|
|
|
(when (derived-mode-p 'org-mode)
|
|
|
|
|
(org-show-context 'agenda)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(and (outline-next-heading)
|
|
|
|
|
(org-flag-heading nil))) ; show the next heading
|
|
|
|
|
(when (outline-invisible-p)
|
|
|
|
|
(outline-show-entry)) ; display invisible text
|
|
|
|
|
(recenter (/ (window-height) 2))
|
|
|
|
|
(org-back-to-heading t)
|
|
|
|
|
(if (re-search-forward org-complex-heading-regexp nil t)
|
|
|
|
|
(goto-char (match-beginning 4))))
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(run-hooks 'org-agenda-after-show-hook))
|
2016-01-07 22:07:28 +00:00
|
|
|
|
|
|
|
|
|
(defun spacemacs-buffer//insert-todo-list (list-display-name list)
|
|
|
|
|
(when (car list)
|
|
|
|
|
(insert list-display-name)
|
|
|
|
|
(setq list (sort list
|
|
|
|
|
(lambda (a b)
|
|
|
|
|
(cond
|
|
|
|
|
((eq "" (cdr (assoc "time" b)))
|
|
|
|
|
t)
|
|
|
|
|
((eq "" (cdr (assoc "time" a)))
|
|
|
|
|
nil)
|
|
|
|
|
(t
|
|
|
|
|
(string< (cdr (assoc "time" a))
|
|
|
|
|
(cdr (assoc "time" b))))))))
|
|
|
|
|
(mapc (lambda (el)
|
|
|
|
|
(insert "\n ")
|
|
|
|
|
(widget-create 'push-button
|
2016-02-01 01:24:13 +00:00
|
|
|
|
:action `(lambda (&rest ignore)
|
|
|
|
|
(spacemacs-buffer//org-jump ',el))
|
2016-01-07 22:07:28 +00:00
|
|
|
|
:mouse-face 'highlight
|
|
|
|
|
:follow-link "\C-m"
|
|
|
|
|
:button-prefix ""
|
|
|
|
|
:button-suffix ""
|
|
|
|
|
:format "%[%t%]"
|
|
|
|
|
(format "%s %s %s"
|
|
|
|
|
(abbreviate-file-name
|
|
|
|
|
(cdr (assoc "file" el)))
|
|
|
|
|
(if (not (eq "" (cdr (assoc "time" el))))
|
|
|
|
|
(format "- %s -"
|
|
|
|
|
(cdr (assoc "time" el)))
|
|
|
|
|
"-")
|
|
|
|
|
(cdr (assoc "text" el)))))
|
|
|
|
|
list)))
|
|
|
|
|
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(defun spacemacs-buffer/insert-startupify-lists ()
|
2015-03-28 14:30:56 +00:00
|
|
|
|
(interactive)
|
2015-12-11 08:08:23 +00:00
|
|
|
|
(with-current-buffer (get-buffer spacemacs-buffer-name)
|
2015-03-28 14:30:56 +00:00
|
|
|
|
(let ((buffer-read-only nil)
|
|
|
|
|
(list-separator "\n\n"))
|
|
|
|
|
(goto-char (point-max))
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(spacemacs-buffer/insert-page-break)
|
2015-03-28 14:30:56 +00:00
|
|
|
|
(mapc (lambda (el)
|
|
|
|
|
(cond
|
|
|
|
|
((eq el 'recents)
|
|
|
|
|
(recentf-mode)
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(when (spacemacs-buffer//insert-file-list
|
|
|
|
|
"Recent Files:"
|
|
|
|
|
(recentf-elements dotspacemacs-startup-recent-list-size))
|
2015-06-03 06:45:54 +00:00
|
|
|
|
(spacemacs//insert--shortcut "r" "Recent Files:")
|
2015-03-28 14:30:56 +00:00
|
|
|
|
(insert list-separator)))
|
2016-01-07 22:07:28 +00:00
|
|
|
|
((eq el 'todos)
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(when (spacemacs-buffer//insert-todo-list
|
|
|
|
|
"ToDo:"
|
|
|
|
|
(spacemacs-buffer//todo-list))
|
2016-01-07 22:07:28 +00:00
|
|
|
|
(spacemacs//insert--shortcut "d" "ToDo:")
|
|
|
|
|
(insert list-separator)))
|
|
|
|
|
((eq el 'agenda)
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(when (spacemacs-buffer//insert-todo-list
|
|
|
|
|
"Agenda:"
|
|
|
|
|
(spacemacs-buffer//agenda-list))
|
2016-01-07 22:07:28 +00:00
|
|
|
|
(spacemacs//insert--shortcut "c" "Agenda:")
|
|
|
|
|
(insert list-separator)))
|
2015-03-28 14:30:56 +00:00
|
|
|
|
((eq el 'bookmarks)
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(when (configuration-layer/layer-usedp 'spacemacs-helm)
|
|
|
|
|
(helm-mode))
|
2016-01-07 17:00:32 +00:00
|
|
|
|
(require 'bookmark)
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(when (spacemacs-buffer//insert-bookmark-list
|
|
|
|
|
"Bookmarks:"
|
|
|
|
|
(bookmark-all-names))
|
2016-01-04 04:00:50 +00:00
|
|
|
|
(spacemacs//insert--shortcut "b" "Bookmarks:")
|
2015-03-28 14:30:56 +00:00
|
|
|
|
(insert list-separator)))
|
2016-04-06 14:05:34 +00:00
|
|
|
|
((and (eq el 'projects)
|
|
|
|
|
(fboundp 'projectile-mode))
|
2015-03-28 14:30:56 +00:00
|
|
|
|
(projectile-mode)
|
2016-02-01 01:24:13 +00:00
|
|
|
|
(when (spacemacs-buffer//insert-file-list
|
|
|
|
|
"Projects:"
|
|
|
|
|
(projectile-relevant-known-projects))
|
2015-06-03 06:45:54 +00:00
|
|
|
|
(spacemacs//insert--shortcut "p" "Projects:")
|
2015-03-28 14:30:56 +00:00
|
|
|
|
(insert list-separator))))) dotspacemacs-startup-lists))))
|
|
|
|
|
|
2015-04-12 04:24:03 +00:00
|
|
|
|
(defun spacemacs-buffer/goto-link-line ()
|
2016-01-27 14:15:34 +00:00
|
|
|
|
"Set point to the beginning of the link line."
|
2015-02-04 04:56:52 +00:00
|
|
|
|
(interactive)
|
2015-07-30 02:07:07 +00:00
|
|
|
|
(with-current-buffer spacemacs-buffer-name
|
|
|
|
|
(goto-char (point-min))
|
2015-12-01 20:02:48 +00:00
|
|
|
|
(with-demoted-errors "spacemacs buffer error: %s"
|
|
|
|
|
(widget-forward 1))))
|
2015-02-04 04:56:52 +00:00
|
|
|
|
|
2016-04-01 03:44:00 +00:00
|
|
|
|
(defun spacemacs-buffer//startup-hook ()
|
|
|
|
|
"Code executed when Emacs has finished loading."
|
|
|
|
|
(with-current-buffer (get-buffer spacemacs-buffer-name)
|
|
|
|
|
(when dotspacemacs-startup-lists
|
|
|
|
|
(spacemacs-buffer/insert-startupify-lists))
|
|
|
|
|
(if configuration-layer-error-count
|
|
|
|
|
(progn
|
|
|
|
|
(spacemacs-buffer-mode)
|
|
|
|
|
(spacemacs-buffer/set-mode-line
|
|
|
|
|
(format
|
|
|
|
|
(concat "%s error(s) at startup! "
|
|
|
|
|
"Spacemacs may not be able to operate properly.")
|
|
|
|
|
configuration-layer-error-count))
|
|
|
|
|
(face-remap-add-relative 'mode-line
|
|
|
|
|
'((:background "red") mode-line)))
|
|
|
|
|
(spacemacs-buffer/set-mode-line spacemacs--default-mode-line)
|
|
|
|
|
(spacemacs-buffer-mode))
|
|
|
|
|
(force-mode-line-update)
|
|
|
|
|
(spacemacs-buffer/goto-link-line)))
|
|
|
|
|
|
2015-10-16 13:17:03 +00:00
|
|
|
|
(defun spacemacs-buffer/goto-buffer ()
|
2015-10-16 14:08:08 +00:00
|
|
|
|
"Create the special buffer for `spacemacs-buffer-mode' if it doesn't
|
2015-10-16 13:17:03 +00:00
|
|
|
|
already exist, and switch to it."
|
|
|
|
|
(interactive)
|
|
|
|
|
(unless (buffer-live-p (get-buffer spacemacs-buffer-name))
|
|
|
|
|
(with-current-buffer (get-buffer-create spacemacs-buffer-name)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(spacemacs-buffer/set-mode-line "")
|
|
|
|
|
;; needed in case the buffer was deleted and we are recreating it
|
|
|
|
|
(setq spacemacs-buffer--note-widgets nil)
|
|
|
|
|
(spacemacs-buffer/insert-banner-and-buttons)
|
2016-03-13 01:37:15 +00:00
|
|
|
|
;; non-nil if emacs-startup-hook was run
|
|
|
|
|
(if (bound-and-true-p spacemacs-initialized)
|
2015-10-16 13:17:03 +00:00
|
|
|
|
(progn
|
|
|
|
|
(when dotspacemacs-startup-lists
|
|
|
|
|
(spacemacs-buffer/insert-startupify-lists))
|
|
|
|
|
(spacemacs-buffer/set-mode-line spacemacs--default-mode-line)
|
|
|
|
|
(force-mode-line-update)
|
|
|
|
|
(spacemacs-buffer-mode))
|
2016-04-01 03:44:00 +00:00
|
|
|
|
(add-hook 'emacs-startup-hook 'spacemacs-buffer//startup-hook t)))))
|
2015-10-16 13:17:03 +00:00
|
|
|
|
(spacemacs-buffer/goto-link-line)
|
2015-12-13 20:32:29 +00:00
|
|
|
|
(switch-to-buffer spacemacs-buffer-name)
|
|
|
|
|
(spacemacs//redisplay))
|
2015-10-16 13:17:03 +00:00
|
|
|
|
|
2015-01-27 03:51:47 +00:00
|
|
|
|
(provide 'core-spacemacs-buffer)
|