|
| 1 | +;;; quicklintjs.el --- Helper functions for quicklintjs Emacs plugins -*- lexical-binding: t; -*- |
| 2 | +;;; Commentary: |
| 3 | + |
| 4 | +;; Shared parts of configuration and code among others Emacs plugins. |
| 5 | + |
| 6 | +;;; Code: |
| 7 | + |
| 8 | +(require 'cl-seq) |
| 9 | + |
| 10 | +(defgroup quicklintjs nil |
| 11 | + "quick-lint-js finds bugs in JavaScript programs." |
| 12 | + :prefix "quicklintjs-" |
| 13 | + :group 'tools |
| 14 | + :group 'processes |
| 15 | + :link '(url-link :tag "Website" "https://quick-lint-js.com")) |
| 16 | + |
| 17 | +(defcustom quicklintjs-program-name "quick-lint-js" |
| 18 | + "quick-lint-js executable to use." |
| 19 | + :group 'quicklintjs |
| 20 | + :type 'string |
| 21 | + :safe 'stringp) |
| 22 | + |
| 23 | +(defcustom quicklintjs-program-args nil |
| 24 | + "Arguments to `quicklintjs-program-name'." |
| 25 | + :group 'quicklintjs |
| 26 | + :type '(repeat 'string)) |
| 27 | + |
| 28 | +(defcustom quicklintjs-find-program-function #'quicklintjs-executable-find |
| 29 | + "Function to find quick-lint-js." |
| 30 | + :group 'quicklintjs |
| 31 | + :type '(choice (const :tag "Search quick-lint-js in `exec-path'" |
| 32 | + quicklintjs-executable-find) |
| 33 | + (const :tag "Search quick-lint-js in node-modules" |
| 34 | + quicklintjs-node-modules-executable-find) |
| 35 | + (function :tag "Function to get quick-lint-js path"))) |
| 36 | + |
| 37 | +;;;###autoload |
| 38 | +(defun quicklintjs-executable-find () |
| 39 | + "Search `quicklintjs-program-name' in `exec-path'." |
| 40 | + (executable-find quicklintjs-program-name)) |
| 41 | + |
| 42 | +;;;###autoload |
| 43 | +(defun quicklintjs-find-program (&rest argv) |
| 44 | + "Make a list of strings by calling `quicklintjs-find-program-function', |
| 45 | +appending `quicklintjs-program-args' and `argv'. |
| 46 | +Empty strings and nil are ignored." |
| 47 | + (cl-remove-if-not (lambda (a) (and (stringp a) |
| 48 | + (> (length a) 0))) |
| 49 | + (append (list (funcall |
| 50 | + quicklintjs-find-program-function)) |
| 51 | + quicklintjs-program-args argv))) |
| 52 | + |
| 53 | +(provide 'quicklintjs) |
| 54 | + |
| 55 | +;; quick-lint-js finds bugs in JavaScript programs. |
| 56 | +;; Copyright (C) 2020 Matthew Glazar |
| 57 | +;; |
| 58 | +;; This file is part of quick-lint-js. |
| 59 | +;; |
| 60 | +;; quick-lint-js is free software: you can redistribute it and/or modify |
| 61 | +;; it under the terms of the GNU General Public License as published by |
| 62 | +;; the Free Software Foundation, either version 3 of the License, or |
| 63 | +;; (at your option) any later version. |
| 64 | +;; |
| 65 | +;; quick-lint-js is distributed in the hope that it will be useful, |
| 66 | +;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 67 | +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 68 | +;; GNU General Public License for more details. |
| 69 | +;; |
| 70 | +;; You should have received a copy of the GNU General Public License |
| 71 | +;; along with quick-lint-js. If not, see <https://www.gnu.org/licenses/>. |
| 72 | + |
| 73 | +;;; quicklintjs.el ends here |
0 commit comments