├── .github ├── dependabot.yml └── workflows │ └── test.yml ├── .gitignore ├── Cask ├── Eask ├── README.org └── projectile-variable.el /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: / 5 | schedule: 6 | interval: daily 7 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | workflow_dispatch: 9 | 10 | concurrency: 11 | group: ${{ github.workflow }}-${{ github.ref }} 12 | cancel-in-progress: true 13 | 14 | jobs: 15 | test: 16 | runs-on: ${{ matrix.os }} 17 | continue-on-error: ${{ matrix.experimental }} 18 | strategy: 19 | fail-fast: false 20 | matrix: 21 | os: [ubuntu-latest, macos-latest, windows-latest] 22 | emacs-version: 23 | - 26.3 24 | - 27.2 25 | - 28.2 26 | - 29.3 27 | experimental: [false] 28 | include: 29 | - os: ubuntu-latest 30 | emacs-version: snapshot 31 | experimental: true 32 | - os: macos-latest 33 | emacs-version: snapshot 34 | experimental: true 35 | - os: windows-latest 36 | emacs-version: snapshot 37 | experimental: true 38 | 39 | steps: 40 | - uses: actions/checkout@v4 41 | 42 | - uses: jcs090218/setup-emacs@master 43 | with: 44 | version: ${{ matrix.emacs-version }} 45 | 46 | - uses: emacs-eask/setup-eask@master 47 | with: 48 | version: 'snapshot' 49 | 50 | - name: Run tests 51 | run: | 52 | eask package 53 | eask install 54 | eask compile 55 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.elc 2 | /.cask/ 3 | /.eask/ 4 | /dist 5 | -------------------------------------------------------------------------------- /Cask: -------------------------------------------------------------------------------- 1 | (package "Cask" "0.0.2" "Store project local variables.") 2 | (source "melpa" "https://melpa.org/packages/") 3 | 4 | (package-file "projectile-variable.el") 5 | 6 | (development 7 | (depends-on "projectile")) 8 | -------------------------------------------------------------------------------- /Eask: -------------------------------------------------------------------------------- 1 | ;; -*- mode: eask; lexical-binding: t -*- 2 | 3 | (package "projectile-variable" 4 | "0.0.2" 5 | "Store project local variables.") 6 | 7 | (website-url "https://github.com/emacs-php/projectile-variable") 8 | (keywords "project" "convenience") 9 | 10 | (package-file "projectile-variable.el") 11 | 12 | (script "test" "echo \"Error: no test specified\" && exit 1") 13 | 14 | (source 'gnu) 15 | (source 'melpa) 16 | 17 | (depends-on "emacs" "24") 18 | (depends-on "cl-lib" "0.5") 19 | 20 | (setq network-security-level 'low) ; see https://github.com/jcs090218/setup-emacs-windows/issues/156#issuecomment-932956432 21 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | * Projectile Variable 2 | 3 | Store project local variables (property) using +[[https://github.com/bbatsov/projectile][Projectile]]+ and [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Symbol-Plists.html][Symbol Plists]]. 4 | The name of this package has =projectile-= in the prefix, but it can now be executed without depending on it. 5 | 6 | #+BEGIN_SRC emacs-lisp 7 | (projectile-variable-put 'foo-value 2) ;; Store property 'foo-value 8 | (projectile-variable-get 'foo-value) ;;=> 2 9 | 10 | ;; Return all project local property list 11 | (projectile-variable-plist) 12 | ;; Return project local property list filterd by prefix "foo-" 13 | (projectile-variable-plist "foo-") 14 | ;; Return all project local properties as association list (alist) 15 | (projectile-variable-alist) 16 | ;; Return project local properties alist filterd by prefix "foo-" 17 | (projectile-variable-alist "foo-") 18 | #+END_SRC 19 | -------------------------------------------------------------------------------- /projectile-variable.el: -------------------------------------------------------------------------------- 1 | ;;; projectile-variable.el --- Store project local variables. -*- lexical-binding: t -*- 2 | 3 | ;; Copyright (C) 2016 USAMI Kenta 4 | 5 | ;; Author: USAMI Kenta 6 | ;; Created: 11 Sep 2016 7 | ;; Version: 0.0.2 8 | ;; Keywords: project, convenience 9 | ;; Homepage: https://github.com/emacs-php/projectile-variable 10 | ;; Package-Requires: ((emacs "24") (cl-lib "0.5")) 11 | 12 | ;; This file is NOT part of GNU Emacs. 13 | 14 | ;; This program is free software; you can redistribute it and/or modify 15 | ;; it under the terms of the GNU General Public License as published by 16 | ;; the Free Software Foundation, either version 3 of the License, or 17 | ;; (at your option) any later version. 18 | 19 | ;; This program is distributed in the hope that it will be useful, 20 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | ;; GNU General Public License for more details. 23 | 24 | ;; You should have received a copy of the GNU General Public License 25 | ;; along with this program. If not, see . 26 | 27 | ;;; Commentary: 28 | 29 | ;; Store project local variables (property) using Projectile and Symbol Plists. 30 | ;; The name of this package has projectile- in the prefix, but it can now be executed without depending on it. 31 | 32 | ;; 33 | ;; - https://github.com/bbatsov/projectile 34 | ;; - https://www.gnu.org/software/emacs/manual/html_node/elisp/Symbol-Plists.html 35 | 36 | ;; (projectile-variable-put 'foo-value 2) ;; Store property 37 | ;; (projectile-variable-get 'foo-value) ;;=> 2 38 | ;; 39 | ;; (projectile-variable-plist) ;; Return all project local property list 40 | ;; (projectile-variable-plist "foo-") ;; Return project local property list filterd by prefix "foo-" 41 | ;; (projectile-variable-alist) ;; Return all project local properties as association list (alist) 42 | ;; (projectile-variable-alist "foo-") ;; Return project local properties alist filterd by prefix "foo-" 43 | 44 | ;;; Code: 45 | (require 'cl-lib) 46 | (require 'projectile nil t) 47 | 48 | (defconst projectile-variable--prefix "projectile-variable--") 49 | 50 | (defgroup projectile-variable nil 51 | "Store project local variables." 52 | :group 'lisp 53 | :prefix "projectile-variable-") 54 | 55 | (defcustom projectile-variable-default-project-root-function #'projectile-project-root 56 | "Default function to retrieve root directory." 57 | :type 'function) 58 | 59 | (defvar projectile-variable-project-root-function nil) 60 | 61 | (defun projectile-variable--get-root () 62 | "Return path to root directory the project." 63 | (if projectile-variable-project-root-function 64 | (funcall projectile-variable-project-root-function) 65 | (if (fboundp projectile-variable-default-project-root-function) 66 | (funcall projectile-variable-default-project-root-function) 67 | (error "Function `%s' is not exists" projectile-variable-default-project-root-function)))) 68 | 69 | (defun projectile-variable--make-symbol () 70 | "Make symbol for save project local variable." 71 | (intern (concat projectile-variable--prefix (projectile-variable--get-root)))) 72 | 73 | (defun projectile-variable-plist (&optional prefix) 74 | "Return project local property list. Fiter properties by prefix if PREFIX is not nil." 75 | (let ((plist (symbol-plist (projectile-variable--make-symbol))) 76 | filtered-plist) 77 | (if (null prefix) 78 | plist 79 | (cl-loop for (prop value) on plist by 'cddr 80 | if (string-prefix-p prefix (symbol-name prop)) 81 | do (setq filtered-plist (plist-put filtered-plist prop value))) 82 | filtered-plist))) 83 | 84 | (defun projectile-variable-alist (&optional prefix) 85 | "Return project local property list as alist. Fiter properties by prefix if PREFIX is not nil." 86 | (let ((plist (symbol-plist (projectile-variable--make-symbol)))) 87 | (cl-loop for (prop value) on plist by 'cddr 88 | if (or (null prefix) (string-prefix-p prefix (symbol-name prop))) 89 | collect (cons prop value)))) 90 | 91 | (defun projectile-variable-put (propname value) 92 | "Store the project local PROPNAME property with value VALUE." 93 | (put (projectile-variable--make-symbol) propname value)) 94 | 95 | (defun projectile-variable-get (propname) 96 | "Return the value of the project local PROPNAME property." 97 | (get (projectile-variable--make-symbol) propname)) 98 | 99 | (provide 'projectile-variable) 100 | ;;; projectile-variable.el ends here 101 | --------------------------------------------------------------------------------