From eef84d4aa9ff628761557300bb9d7f151914595b Mon Sep 17 00:00:00 2001 From: Yasuyuki Oka Date: Sat, 5 Nov 2016 23:30:20 +0900 Subject: [PATCH 1/2] Fix package-lint warnings --- .gitignore | 2 -- Cask | 1 + Makefile | 33 ++++++++++++++++----------------- README.md | 6 +++--- helm-git-grep.el | 34 +++++++++++++++++++++------------- 5 files changed, 41 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index fe7373d..9fb9c15 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,3 @@ .elc* elpa test/fixture/* -test/test-package-install.log -test/test-checkdoc.log diff --git a/Cask b/Cask index 956e36e..34d1de5 100644 --- a/Cask +++ b/Cask @@ -6,6 +6,7 @@ (development (depends-on "cask") + (depends-on "package-lint") (depends-on "f") (depends-on "ert") ; Unit test library (depends-on "ert-runner") ; Unit test runner diff --git a/Makefile b/Makefile index b1dfcb9..958b93a 100644 --- a/Makefile +++ b/Makefile @@ -5,14 +5,17 @@ SRC ?= helm-git-grep.el FIXTURE_GIT_VERSION ?= v1.0.0 FIXTURE_GIT_WORK_DIR ?= test/fixture/git TEST_CHECKDOC_EL ?= test/test-checkdoc.el -TEST_CHECKDOC_LOG ?= test/test-checkdoc.log TEST_PACKAGE_INSTALL_EL ?= test/test-package-install.el -TEST_PACKAGE_INSTALL_LOG ?= test/test-package-install.log LOADPATH = -L . ELPA_DIR = $(shell EMACS=$(EMACS) $(CASK) package-directory) +INIT_PACKAGE_EL="(progn (require 'cask) (cask-initialize \".\"))" + .PHONY : test -test: test-checkdoc test-package-install unit-tests +test: test-checkdoc package-lint test-package-install unit-tests + +.PHONY : travis-ci +travis-ci: print-deps package-lint test-package-install unit-tests .PHONY : unit-tests # `clean-elc` task needs to remove byte-compiled files to collect coverage by undercover.el. @@ -26,7 +29,7 @@ clean-elpa: .PHONY : clean-elc clean-elc: - cask clean-elc + ${CASK} clean-elc .PHONY : clean clean: clean-elpa clean-elc clean-fixture @@ -39,22 +42,18 @@ print-deps: .PHONY : test-checkdoc test-checkdoc: elpa @echo "-- test ckeckdoc --" - $(CASK) exec $(EMACS) -batch -Q $(LOADPATH) -l $(TEST_CHECKDOC_EL) 2>&1 | tee $(TEST_CHECKDOC_LOG) - @cat $(TEST_CHECKDOC_LOG) | [ $$(wc -l) -gt 0 ] && exit 1 || exit 0 + $(CASK) exec $(EMACS) -batch -Q $(LOADPATH) -l $(TEST_CHECKDOC_EL) 2>&1 | tee /dev/tty | [ $$(wc -l) -gt 0 ] && exit 1 || exit 0 -.PHONY : test-package-install -test-package-install: elpa clean-package-install - @echo "-- test install package --" - $(CASK) exec $(EMACS) -batch -Q $(LOADPATH) -l $(TEST_PACKAGE_INSTALL_EL) 2>&1 | tee $(TEST_PACKAGE_INSTALL_LOG) - @grep Error $(TEST_PACKAGE_INSTALL_LOG) && exit 1 || exit 0 -.PHONY : clean-package-install -clean-package-install: - rm -rf $(ELPA_DIR)/helm-git-grep* - rm -rf $(TEST_PACKAGE_INSTALL_LOG) +.PHONY : package-lint +package-lint: elpa + @echo "-- package lint --" + $(CASK) exec $(EMACS) -batch -Q --eval $(INIT_PACKAGE_EL) -l package-lint.el -f package-lint-batch-and-exit $(SRC) -.PHONY : travis-ci -travis-ci: print-deps test-package-install unit-tests +.PHONY : test-package-install +test-package-install: elpa + @echo "-- test install package --" + $(CASK) exec $(EMACS) -batch -Q $(LOADPATH) -l $(TEST_PACKAGE_INSTALL_EL) 2>&1 | tee /dev/tty | grep Error > /dev/null && exit 1 || exit 0 .PHONY : elpa elpa: $(ELPA_DIR) diff --git a/README.md b/README.md index c9a2c67..a43b90f 100644 --- a/README.md +++ b/README.md @@ -159,13 +159,13 @@ A buffer name is `*helm git grep*` without ignore case option. #### `helm-git-grep-sources` -**(Default: `'(helm-source-git-grep helm-source-git-submodule-grep)`)** +**(Default: `'(helm-git-grep-source helm-git-grep-submodule-source)`)** Default helm sources for `helm-git-grep`. -If you don't want to search in submodules, Set only `helm-source-git-grep` like this: +If you don't want to search in submodules, Set only `helm-git-grep-source` like this: - (setq helm-git-grep-sources '(helm-source-git-grep)) + (setq helm-git-grep-sources '(helm-git-grep-sources)) #### `helm-git-grep-candidate-number-limit` diff --git a/helm-git-grep.el b/helm-git-grep.el index 758b139..4a1992a 100644 --- a/helm-git-grep.el +++ b/helm-git-grep.el @@ -10,7 +10,6 @@ ;; Version: 0.10.0-snapshot ;; URL: https://github.com/yasuyk/helm-git-grep ;; Package-Requires: ((helm-core "2.2.0")) -;; Keywords: helm, git ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -60,13 +59,13 @@ :group 'helm) (defcustom helm-git-grep-sources - '(helm-source-git-grep helm-source-git-submodule-grep) + '(helm-git-grep-source helm-git-grep-submodule-source) "Default helm sources for `helm-git-grep'. If you don't want to search in submodules, \ -Set only `helm-source-git-grep' like this: +Set only `helm-git-grep-source' like this: - (setq helm-git-grep-sources '(helm-source-git-grep))" + (setq helm-git-grep-sources '(helm-git-grep-source))" :group 'helm-gi-grep :type '(repeat (choice symbol))) @@ -261,7 +260,7 @@ newline return an empty string." (split-string helm-pattern " +" t)))) (helm-git-grep-pathspec-args)))) -(defun helm-git-submodule-grep-command () +(defun helm-git-grep-submodule-grep-command () "Create command of `helm-git-submodule-grep-process' in `helm-git-grep'." (list "git" "--no-pager" "submodule" "--quiet" "foreach" (format "git grep -n --no-color %s %s %s | sed s!^!$path/!" @@ -278,12 +277,12 @@ newline return an empty string." (let ((default-directory it)) (apply 'start-process "git-grep-process" nil "git" (helm-git-grep-args))) '())) -(defun helm-git-submodule-grep-process () +(defun helm-git-grep-submodule-grep-process () "Retrieve candidates from result of git grep submodules." (helm-aif (helm-attr 'base-directory) (let ((default-directory it)) (apply 'start-process "git-submodule-grep-process" nil - (helm-git-submodule-grep-command))) + (helm-git-grep-submodule-grep-command))) '())) (define-compilation-mode helm-git-grep-mode "Helm Git Grep" @@ -642,7 +641,7 @@ You can save your results in a helm-git-grep-mode buffer, see below. (delq nil map)) "Keymap used in Git Grep sources.") -(eval `(defclass helm-git-grep-source (helm-source-async) +(eval `(defclass helm-git-grep-class (helm-source-async) ((header-name :initform helm-git-grep-header-name) (default-directory :initform nil) (requires-pattern :initform 2) @@ -657,13 +656,13 @@ You can save your results in a helm-git-grep-mode buffer, see below. (keymap :initform ,helm-git-grep-map) (init :initform helm-git-grep-init)))) -(defvar helm-source-git-grep - (helm-make-source "Git Grep" 'helm-git-grep-source +(defvar helm-git-grep-source + (helm-make-source "Git Grep" 'helm-git-grep-class :candidates-process 'helm-git-grep-process)) -(defvar helm-source-git-submodule-grep - (helm-make-source "Git Submodule Grep" 'helm-git-grep-source - :candidates-process 'helm-git-submodule-grep-process)) +(defvar helm-git-grep-submodule-source + (helm-make-source "Git Submodule Grep" 'helm-git-grep-class + :candidates-process 'helm-git-grep-submodule-grep-process)) (defun helm-git-grep-1 (&optional input) "Execute helm git grep. @@ -735,6 +734,15 @@ if region exists. 'helm-git-grep-with-exclude-file-pattern helm-git-grep-with-exclude-file-pattern-obsolete-message "0.10.0") +(define-obsolete-function-alias 'helm-git-submodule-grep-command + 'helm-git-grep-submodule-grep-command "0.10.0") + +(define-obsolete-function-alias 'helm-git-submodule-grep-process + 'helm-git-grep-submodule-grep-process "0.10.0") + +(define-obsolete-variable-alias 'helm-source-git-grep + 'helm-git-grep-source "0.10.0") + (provide 'helm-git-grep) From f1929b4240dc5dd213c9876637c1c13164dc86f4 Mon Sep 17 00:00:00 2001 From: Yasuyuki Oka Date: Sat, 5 Nov 2016 23:58:29 +0900 Subject: [PATCH 2/2] Add test for autoload functions --- test/test-package-install.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/test-package-install.el b/test/test-package-install.el index 7278d28..4dcba8a 100644 --- a/test/test-package-install.el +++ b/test/test-package-install.el @@ -3,3 +3,15 @@ (setq byte-compile-error-on-warn t) (require 'package) (package-install-file "helm-git-grep.el") + +(defun should-autoload (c) + (let ((s (symbol-function c))) + (unless (autoloadp s) + (message "Error: %s is not autoload" c) + (kill-emacs 1)))) + +(should-autoload 'helm-git-grep-ls-files-limited-by-pathspec) +(should-autoload 'helm-git-grep) +(should-autoload 'helm-git-grep-from-isearch) +(should-autoload 'helm-git-grep-with-exclude-file-pattern) +(should-autoload 'helm-git-grep-from-helm)