diff --git a/Makefile b/Makefile index 9fd7d77..c9e1d35 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,10 @@ EMACS ?= $(shell which emacs) -SRC=$(shell cask files) +export CASK := $(shell which cask) +ifeq ($(CASK),) +$(error Please install CASK at https://cask.readthedocs.io/en/latest/guide/installation.html) +endif +CASK_DIR := $(shell EMACS=$(EMACS) cask package-directory || exit 1) +SRC=$(shell $(CASK) files) PKBUILD=2.3 ELCFILES = $(SRC:.el=.elc) @@ -31,18 +36,24 @@ README.rst: README.in.rst nnhackernews.el test-clean: rm -rf tests/.emacs* tests/.newsrc* tests/Mail tests/News tests/request tests/request-log +.PHONY: cask +cask: $(CASK_DIR) + +$(CASK_DIR): Cask + $(CASK) install + touch $(CASK_DIR) + .PHONY: clean clean: test-clean - cask clean-elc + $(CASK) clean-elc rm -f tests/log/* rm -rf tests/test-install .PHONY: test-compile -test-compile: - cask install +test-compile: cask sh -ex tools/package-lint.sh nnhackernews.el - ! (cask eval "(let ((byte-compile-error-on-warn t)) (cask-cli/build))" 2>&1 | egrep -a "(Warning|Error):") - cask clean-elc + ! ($(CASK) eval "(let ((byte-compile-error-on-warn t)) (cask-cli/build))" 2>&1 | egrep -a "(Warning|Error):") + $(CASK) clean-elc .PHONY: test-install test-install: @@ -74,14 +85,14 @@ test-install: .PHONY: test-unit test-unit: - cask exec ert-runner -L . -L tests tests/test*.el + $(CASK) exec ert-runner -L . -L tests tests/test*.el .PHONY: test test: test-compile test-unit test-int .PHONY: test-int test-int: test-clean - cask exec ecukes --reporter magnars --debug + $(CASK) exec ecukes --reporter magnars --debug .PHONY: dist-clean dist-clean: @@ -89,7 +100,7 @@ dist-clean: .PHONY: dist dist: dist-clean - cask package + $(CASK) package .PHONY: install install: test-compile dist diff --git a/README.in.rst b/README.in.rst index 748c2e2..89f7eac 100644 --- a/README.in.rst +++ b/README.in.rst @@ -30,6 +30,7 @@ Then :: M-x package-refresh-contents RET + M-x package-initialize RET M-x package-install RET nnhackernews RET Alternatively, copy ``nnhackernews.el`` to a directory among ``C-h v RET load-path`` and add ``(require 'nnhackernews)`` to ``.emacs``. diff --git a/README.rst b/README.rst index 4ded675..ccc9a5f 100644 --- a/README.rst +++ b/README.rst @@ -30,6 +30,7 @@ Then :: M-x package-refresh-contents RET + M-x package-initialize RET M-x package-install RET nnhackernews RET Alternatively, copy ``nnhackernews.el`` to a directory among ``C-h v RET load-path`` and add ``(require 'nnhackernews)`` to ``.emacs``. diff --git a/nnhackernews.el b/nnhackernews.el index 85f8abb..e25a8b0 100644 --- a/nnhackernews.el +++ b/nnhackernews.el @@ -483,7 +483,7 @@ If GROUP classification omitted, figure it out." (defmacro nnhackernews--with-group (group &rest body) "Disambiguate GROUP if it's empty and execute BODY." (declare (debug (form &rest form)) - (indent 1)) + (indent defun)) `(let* ((group (or ,group (gnus-group-real-name gnus-newsgroup-name))) (gnus-newsgroup-name (gnus-group-full-name group "nnhackernews:"))) ,@body)) @@ -631,9 +631,11 @@ FORCE is generally t unless coming from `nnhackernews--score-pending'." "Filter unread messages for GROUP now. Otherwise *Group* buffer annoyingly overrepresents unread." - (nnhackernews--with-group group - (unless (nnhackernews-extant-summary-buffer gnus-newsgroup-name) - (nnhackernews--rescore gnus-newsgroup-name t)))) + (when (or (gnus-native-method-p '(nnhackernews "")) + (gnus-secondary-method-p '(nnhackernews ""))) + (nnhackernews--with-group group + (unless (nnhackernews-extant-summary-buffer gnus-newsgroup-name) + (nnhackernews--rescore gnus-newsgroup-name t))))) (defun nnhackernews--mark-scored-as-read (group) "If a root article (story) is scored in GROUP, that means we've already read it." @@ -1539,31 +1541,29 @@ Written by John Wiegley (https://github.com/jwiegley/dot-emacs).") (when (nnhackernews--gate) (nnhackernews-summary-mode))) -(when (or (gnus-native-method-p '(nnhackernews "")) - (gnus-secondary-method-p '(nnhackernews ""))) - ;; I believe I did try buffer-localizing hooks, and it wasn't sufficient - (add-hook 'gnus-article-mode-hook #'nnhackernews-article-mode-activate) - (add-hook 'gnus-summary-mode-hook #'nnhackernews-summary-mode-activate) +;; I believe I did try buffer-localizing hooks, and it wasn't sufficient +(add-hook 'gnus-article-mode-hook #'nnhackernews-article-mode-activate) +(add-hook 'gnus-summary-mode-hook #'nnhackernews-summary-mode-activate) + +;; Avoid having to select the GROUP to make the unread number go down. +(mapc (lambda (hook) + (add-hook hook + (lambda () (mapc (lambda (group) + (nnhackernews--score-unread group)) + `(,nnhackernews--group-ask + ,nnhackernews--group-show + ,nnhackernews--group-job + ,nnhackernews--group-stories))))) + '(gnus-after-getting-new-news-hook)) +;; (add-hook 'gnus-started-hook +;; (lambda () (mapc (lambda (group) +;; (nnhackernews--mark-scored-as-read group)) +;; `(,nnhackernews--group-ask +;; ,nnhackernews--group-show +;; ,nnhackernews--group-job +;; ,nnhackernews--group-stories))) +;; t) - ;; Avoid having to select the GROUP to make the unread number go down. - (mapc (lambda (hook) - (add-hook hook - (lambda () (mapc (lambda (group) - (nnhackernews--score-unread group)) - `(,nnhackernews--group-ask - ,nnhackernews--group-show - ,nnhackernews--group-job - ,nnhackernews--group-stories))))) - '(gnus-after-getting-new-news-hook)) - ;; (add-hook 'gnus-started-hook - ;; (lambda () (mapc (lambda (group) - ;; (nnhackernews--mark-scored-as-read group)) - ;; `(,nnhackernews--group-ask - ;; ,nnhackernews--group-show - ;; ,nnhackernews--group-job - ;; ,nnhackernews--group-stories))) - ;; t) - ) ;; "Can't figure out hook that can remove itself (quine conundrum)" (add-function :around (symbol-function 'gnus-summary-exit) @@ -1661,19 +1661,17 @@ Written by John Wiegley (https://github.com/jwiegley/dot-emacs).") :around (symbol-function 'message-is-yours-p) (lambda (f &rest args) (let ((concat-func (lambda (f &rest args) - (let ((fetched (apply f args))) - (if (string= (car args) "from") - (concat fetched "@ycombinator.com") - fetched))))) + (let ((fetched (apply f args))) + (if (string= (car args) "from") + (concat fetched "@ycombinator.com") + fetched))))) (when (nnhackernews--gate) (add-function :around (symbol-function 'message-fetch-field) concat-func)) - (condition-case err - (prog1 (apply f args) - (remove-function (symbol-function 'message-fetch-field) concat-func)) - (error (remove-function (symbol-function 'message-fetch-field) concat-func) - (error (error-message-string err))))))) + (unwind-protect + (apply f args) + (remove-function (symbol-function 'message-fetch-field) concat-func))))) (let ((protect (lambda (caller) (add-function diff --git a/tools/install-virtualenv.sh b/tools/install-virtualenv.sh index 05beee1..76e86df 100644 --- a/tools/install-virtualenv.sh +++ b/tools/install-virtualenv.sh @@ -13,8 +13,8 @@ if [ "x$TRAVIS_OS_NAME" = "xosx" ]; then case "${TOXENV}" in py27) - pyenv install -s 2.7.12 - pyenv virtualenv -f 2.7.12 py27 + pyenv install -s 2.7.13 + pyenv virtualenv -f 2.7.13 py27 ;; py35) pyenv install -s 3.5.2