Skip to content

Commit

Permalink
Add back support for Emacs 24.4 and 24.5
Browse files Browse the repository at this point in the history
- re-add purpose-alist-get
- fix Package-Requires
- re-add name argument for purpose-conf objects (turns out it is
  still mandatory in 24.5, only made obsolete in 25.1)
  • Loading branch information
bmag committed Aug 9, 2018
1 parent a60c0ef commit 8c923bb
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ dist
# Ecukes
/features/project/.cask
/features/project/test/*.el
/test/user-input.txt
3 changes: 2 additions & 1 deletion window-purpose-configuration.el
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ configuration.
Example:
(purpose-set-extension-configuration
:python
(purpose-conf :mode-purposes
(purpose-conf \"py\"
:mode-purposes
'((python-mode . python)
(inferior-python-mode . interpreter))))
Expand Down
7 changes: 5 additions & 2 deletions window-purpose-fixes.el
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ This function should be advised around

;;; Helm's buffers should be ignored, and they should have their own purpose
(defvar purpose--helm-conf
(purpose-conf :regexp-purposes '(("^\\*Helm" . helm)
(purpose-conf "helm"
:regexp-purposes '(("^\\*Helm" . helm)
("^\\*helm" . helm)))
"Purpose configuration for helm.")
(defun purpose--fix-helm ()
Expand Down Expand Up @@ -130,7 +131,7 @@ When `purpose--active-p' is nil, call original `neo-global--create-window'."
;; `purpose--special-action-sequence' will try to call it)
(purpose-set-extension-configuration
:neotree
(purpose-conf :name-purposes `((,neo-buffer-name . Neotree))))
(purpose-conf "Neotree" :name-purposes `((,neo-buffer-name . Neotree))))
(add-to-list 'purpose-special-action-sequences
'(Neotree purpose-display-reuse-window-buffer
purpose-display-reuse-window-purpose
Expand Down Expand Up @@ -198,6 +199,7 @@ Don't call this function before `popwin' is loaded."
'(purpose-set-extension-configuration
:guide-key
(purpose-conf
"guide-key"
:name-purposes `((,guide-key/guide-buffer-name . guide-key))))))


Expand All @@ -212,6 +214,7 @@ Don't call this function before `popwin' is loaded."
(purpose-set-extension-configuration
:which-key
(purpose-conf
"which-key"
:name-purposes `((,which-key-buffer-name . which-key)))))))


Expand Down
2 changes: 1 addition & 1 deletion window-purpose-switch.el
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ If ALIST is nil, it is ignored and `purpose--alist' is used instead."
(let* ((user-action-sequence .user-action-sequence)
(special-action-sequence (purpose--special-action-sequence buffer
alist))
(normal-action-sequence (alist-get
(normal-action-sequence (purpose-alist-get
(or .action-order
purpose-default-action-order)
purpose-action-sequences))
Expand Down
11 changes: 11 additions & 0 deletions window-purpose-utils.el
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ return the formatted string. FORMAT-STRING and ARGS are passed to
(apply #'message format-string args)
(apply #'format format-string args)))

;; define our (limited) version of alist-get
(defun purpose-alist-get (key alist &optional default _remove)
"Get KEY's value in ALIST.
If no such key, return DEFAULT.
When setting KEY's value, if the new value is equal to DEFAULT and
REMOVE is non-nil, then delete the KEY instead."
(let ((entry (assq key alist)))
(if entry
(cdr entry)
default)))

(defun purpose-alist-set (key value alist)
"Set VALUE to be the value associated to KEY in ALIST.
This doesn't change the original alist, but returns a modified copy."
Expand Down
11 changes: 8 additions & 3 deletions window-purpose-x.el
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@
Has a main 'edit window, and two side windows - 'dired and 'buffers.
All windows are purpose-dedicated.")

;; the name arg ("purpose-x-code1") is necessary for Emacs 24.3 and older
;; the name arg ("purpose-x-code1") is necessary for Emacs 24.5 and older
;; (omitting it produces an "Invalid slot name" error)
(defvar purpose-x-code1-purpose-config
(purpose-conf :mode-purposes
(purpose-conf "purpose-x-code1"
:mode-purposes
'((ibuffer-mode . buffers)
(dired-mode . dired)
(imenu-list-major-mode . ilist))))
Expand Down Expand Up @@ -189,11 +191,13 @@ imenu."
;;; - `purpose-x-magit-off'

(defvar purpose-x-magit-single-conf
(purpose-conf :regexp-purposes '(("^\\*magit" . magit)))
(purpose-conf "magit-single"
:regexp-purposes '(("^\\*magit" . magit)))
"Configuration that gives each magit major mode the same purpose.")

(defvar purpose-x-magit-multi-conf
(purpose-conf
"magit-multi"
:mode-purposes '((magit-diff-mode . magit-diff)
(magit-status-mode . magit-status)
(magit-log-mode . magit-log)
Expand Down Expand Up @@ -381,6 +385,7 @@ The configuration is updated according to
(interactive)
(cl-flet ((joiner (x) (cons x 'popup)))
(let ((conf (purpose-conf
"popwin"
:mode-purposes (mapcar #'joiner purpose-x-popwin-major-modes)
:name-purposes (mapcar #'joiner purpose-x-popwin-buffer-names)
:regexp-purposes (mapcar #'joiner
Expand Down
2 changes: 1 addition & 1 deletion window-purpose.el
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
;; Version: 1.6.1
;; Keywords: frames
;; Homepage: https://github.com/bmag/emacs-purpose
;; Package-Requires: ((emacs "25") (imenu-list "0.1"))
;; Package-Requires: ((emacs "24.4") (let-alist "1.0.3") (imenu-list "0.1"))

;; This file is not part of GNU Emacs.

Expand Down

0 comments on commit 8c923bb

Please sign in to comment.