Skip to content

Commit

Permalink
Merge branch 'master' into fix-isearch
Browse files Browse the repository at this point in the history
  • Loading branch information
wyuenho authored Feb 13, 2021
2 parents 255167d + b131315 commit 4cf4ba5
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 58 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches:
- '*'
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
emacs_version:
- '25.3'
- '26.3'
- '27.1'
- 'snapshot'
cask_version:
- 'snapshot'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.9'
architecture: 'x64'
- uses: purcell/setup-emacs@master
with:
version: ${{ matrix.emacs_version }}

- uses: conao3/setup-cask@master
with:
version: 'snapshot'

- name: Run tests
env:
COVERALLS_FLAG_NAME: Emacs ${{ matrix.emacs_version }}
COVERALLS_PARALLEL: 1
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
make install
make test
send-coverage-report:
runs-on: ubuntu-latest
if: always()
needs: test
steps:
- run: curl "https://coveralls.io/webhook?repo_name=$GITHUB_REPOSITORY&repo_token=${{ secrets.GITHUB_TOKEN }}" -d "payload[build_num]=$GITHUB_RUN_NUMBER&payload[status]=done"
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

8 changes: 4 additions & 4 deletions window-purpose-configuration.el
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ purpose of a buffer. The user configuration and extended configuration
are used anyway."
:group 'purpose
:type 'boolean
:package-version "1.2")
:package-version '(window-purpose . "1.2"))

(defcustom purpose-user-mode-purposes nil
"User configured alist mapping of modes to purposes.
Expand All @@ -143,7 +143,7 @@ If you set this variable in elisp-code, you should call the function
(prog1 (set-default symbol value)
(purpose-compile-user-configuration)))
:initialize 'custom-initialize-default
:package-version "1.2")
:package-version '(window-purpose . "1.2"))

(defcustom purpose-user-name-purposes nil
"User configured alist mapping of names to purposes.
Expand All @@ -157,7 +157,7 @@ If you set this variable in elisp-code, you should call the function
(prog1 (set-default symbol value)
(purpose-compile-user-configuration)))
:initialize 'custom-initialize-default
:package-version "1.2")
:package-version '(window-purpose . "1.2"))

(defcustom purpose-user-regexp-purposes nil
"User configured alist mapping of regexps to purposes.
Expand All @@ -171,7 +171,7 @@ If you set this variable in elisp-code, you should call the function
(prog1 (set-default symbol value)
(purpose-compile-user-configuration)))
:initialize 'custom-initialize-default
:package-version "1.2")
:package-version '(window-purpose . "1.2"))

(defvar purpose-extended-configuration nil
"A plist containing `purpose-conf' objects.
Expand Down
6 changes: 3 additions & 3 deletions window-purpose-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@
"purpose-mode configuration"
:group 'windows
:prefix "purpose-"
:package-version "1.2")
:package-version '(window-purpose . "1.2"))

(defcustom default-purpose 'general
"The default purpose for buffers which didn't get another purpose."
:group 'purpose
:type 'symbol
:package-version "1.2")
:package-version '(window-purpose . "1.2"))

(defcustom default-file-purpose 'edit
"The default purpose for buffers visiting a file which didn't get a purpose."
:group 'purpose
:type 'symbol
:package-version "1.6.1")
:package-version '(window-purpose . "1.6.1"))

;;; utilities

Expand Down
72 changes: 69 additions & 3 deletions window-purpose-fixes.el
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,33 @@
(require 'window-purpose-switch)
(require 'window-purpose-configuration)


(defun purpose--fix-edebug ()
"Integrates Edebug with Purpose."

(with-eval-after-load 'edebug
(defun purpose--edebug-pop-to-buffer-advice (buffer &optional window)
"Reimplements `edebug-pop-to-buffer' using `pop-to-buffer'
Since `edebug-pop-to-buffer' simply splits the last selected
window before the minibuffer was popped up, the window it picks
to display a edebug buffer does not respect `window-purpose' as
all. This advice reimplements it by replacing the window
spliting logic with `pop-to-buffer'."
(setq window
(cond
((and (edebug-window-live-p window)
(eq (window-buffer window) buffer))
window)
((eq (window-buffer) buffer)
(selected-window))
((get-buffer-window buffer 0))
(t (get-buffer-window (pop-to-buffer buffer)))))
(set-window-buffer window buffer)
(select-window window)
(unless (memq (framep (selected-frame)) '(nil t pc))
(x-focus-frame (selected-frame)))
(set-window-hscroll window 0))
(advice-add 'edebug-pop-to-buffer :override 'purpose--edebug-pop-to-buffer-advice)))

;;; `compilation-next-error-function' sometimes hides the compilation buffer
;;; when Purpose is on. Solution: make the buffer's window dedicated while
Expand Down Expand Up @@ -58,6 +84,23 @@ Prevents `isearch-describe-*' commands from bypassing purpose."
(setq isearch--display-help-action '(purpose--action-function . nil))))


(defun purpose--fix-next-error ()
"Integrate `window-purpose' and `next-error'.
Under `next-error-follow-minor-mode', `next-error-no-select' will
override window-purpose's `display-buffer-overriding-action'.
This will result in source buffers not displaying in the
purpose-dedicated window for source code in complex window
layouts. This fix makes sure `next-error' works with
window-purpose."
(defun purpose--next-error (oldfun &rest args)
"Make sure `next-error' respects `purspose--action-function'."
(interactive (lambda (spec) (advice-eval-interactive-spec spec)))
(let ((display-buffer-overriding-action '(purpose--action-function . nil)))
(apply oldfun args)))
(advice-add 'next-error :around 'purpose--next-error))


;;; Hydra's *LV* buffer should be ignored by Purpose
(defun purpose--fix-hydra-lv ()
"Add hydra's LV buffer to Purpose's ignore list."
Expand Down Expand Up @@ -254,28 +297,49 @@ Don't call this function before `popwin' is loaded."
(add-to-list 'purpose-special-action-sequences
'(Zone display-buffer-same-window))))


(defun purpose--fix-whitespace ()
"Integrate `window-purpose' with `whitespace'."
(with-eval-after-load 'whitespace
(defun purpose--whitespace-display-window-advice (buffer)
"Stops `whitespace-display-window' from splitting and shrinking windows."
(with-current-buffer buffer
(special-mode)
(goto-char (point-min)))
(switch-to-buffer buffer))
(advice-add 'whitespace-display-window :override
'purpose--whitespace-display-window-advice)))


;;; install fixes

(defun purpose-fix-install (&rest exclude)
"Install fixes for integrating Purpose with other features.
EXCLUDE is a list of integrations to skip. Known members of EXCLUDE
are:
- 'edebug : don't integrate with edebug
- 'compilation-next-error-function : don't integrate with
`compilation-next-error-function'.
- 'isearch : don't integrate with isearch
- 'next-error : don't integrate with `next-error'
- 'lv : don't integrate with lv (hydra)
- 'helm : don't integrate with helm
- 'neotree : don't integrate with neotree
- 'org : don't integrate with org
- 'popwin : don't integrate with popwin
- 'guide-key : don't integrate with guide-key
- 'which-key : don't integrate with which-key"
- 'which-key : don't integrate with which-key
- 'whitespace : don't integrate with whitespace"
(interactive)
(unless (member 'edebug exclude)
(purpose--fix-edebug))
(unless (member 'compilation-next-error-function exclude)
(advice-add 'compilation-next-error-function
:around #'purpose--fix-compilation-next-error))
(unless (member 'isearch exclude)
(purpose--fix-isearch))
(unless (member 'next-error exclude)
(purpose--fix-next-error))
(unless (member 'lv exclude)
(purpose--fix-hydra-lv))
(unless (member 'helm exclude)
Expand All @@ -293,7 +357,9 @@ are:
(unless (member 'magit-popup exclude)
(purpose--fix-magit-popup))
(unless (member 'zone exclude)
(purpose--fix-zone)))
(purpose--fix-zone))
(unless (member 'whitespace exclude)
(purpose--fix-whitespace)))

(provide 'window-purpose-fixes)
;;; window-purpose-fixes.el ends here
10 changes: 5 additions & 5 deletions window-purpose-layout.el
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,29 @@
"If nil, don't use layouts from `purpose--built-in-layouts-dir'."
:group 'purpose
:type 'boolean
:package-version "1.6")
:package-version '(window-purpose . "1.6"))

(defcustom purpose-default-layout-file
(concat user-emacs-directory ".purpose-layout")
"Default file for saving/loading purpose layout."
:group 'purpose
:type 'file
:package-version "1.2")
:package-version '(window-purpose . "1.2"))

(defcustom purpose-layout-dirs
(list (locate-user-emacs-file "layouts/"))
"List of directories containing layout files."
:group 'purpose
:type '(repeat file)
:package-version "1.5")
:package-version '(window-purpose . "1.5"))

(defcustom purpose-get-extra-window-params-functions nil
"If non-nil, this variable should be a list of functions.
This variable is used by `purpose-window-params'. See
`purpose-window-params' for more details."
:group 'purpose
:type 'hook
:package-version "1.4")
:package-version '(window-purpose . "1.4"))

(defcustom purpose-set-window-properties-functions nil
"Hook to run after calling `purpose-set-window-properties'.
Expand All @@ -75,7 +75,7 @@ WINDOW is nil, your function should act on the selected window
instead."
:group 'purpose
:type 'hook
:package-version "1.2")
:package-version '(window-purpose . "1.2"))

(defvar purpose-recent-window-layouts (make-ring 50)
"Most recently used window layouts.
Expand Down
14 changes: 7 additions & 7 deletions window-purpose-switch.el
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@ Any other value is treated the same as nil."
(const error)
(const nil)
function)
:package-version "1.4")
:package-version '(window-purpose . "1.4"))

(defcustom purpose-display-buffer-functions nil
"Hook to run after displaying a buffer with `purpose--action-function'.
This hook is called with one argument - the window used for display."
:group 'purpose
:type 'hook
:package-version "1.4")
:package-version '(window-purpose . "1.4"))

(defcustom purpose-select-buffer-hook nil
"Hook to run after selecting a buffer with `purpose-select-buffer'."
:group 'purpose
:type 'hook
:package-version "1.2")
:package-version '(window-purpose . "1.2"))

(defvar purpose--active-p nil
"When nil, Purpose's advices and `purpose--action-function' are not
Expand Down Expand Up @@ -139,7 +139,7 @@ case, `purpose-display-at-top-height' is ignored."
:group 'purpose
:type '(choice number
(const nil))
:package-version "1.4")
:package-version '(window-purpose . "1.4"))

(defcustom purpose-display-at-bottom-height 8
"Height for new windows created by `purpose-display-at-bottom'.
Expand All @@ -153,7 +153,7 @@ this case, `purpose-display-at-bottom-height' is ignored."
:group 'purpose
:type '(choice number
(const nil))
:package-version "1.4")
:package-version '(window-purpose . "1.4"))

(defcustom purpose-display-at-left-width 32
"Width for new windows created by `purpose-display-at-left'.
Expand All @@ -166,7 +166,7 @@ case, `purpose-display-at-left-width' is ignored."
:group 'purpose
:type '(choice number
(const nil))
:package-version "1.4")
:package-version '(window-purpose . "1.4"))

(defcustom purpose-display-at-right-width 32
"Width for new windows created by `purpose-display-at-right'.
Expand All @@ -180,7 +180,7 @@ this case, `purpose-display-at-right-width' is ignored."
:group 'purpose
:type '(choice number
(const nil))
:package-version "1.4")
:package-version '(window-purpose . "1.4"))



Expand Down
2 changes: 1 addition & 1 deletion window-purpose-utils.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
Toggling this on will cause Purpose to produce some debug messages."
:group 'purpose
:type 'boolean
:package-version "1.2")
:package-version '(window-purpose . "1.2"))

(defun purpose-message (format-string &rest args)
"Produce a message if `purpose-message-on-p' is non-nil.
Expand Down
Loading

0 comments on commit 4cf4ba5

Please sign in to comment.