[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] scratch/editorconfig-cc e7a0874591 026/351: Add hook mechanism.
From: |
Stefan Monnier |
Subject: |
[nongnu] scratch/editorconfig-cc e7a0874591 026/351: Add hook mechanism. |
Date: |
Thu, 13 Jun 2024 18:38:38 -0400 (EDT) |
branch: scratch/editorconfig-cc
commit e7a0874591b23885e10dc322211ff9f77b944dae
Author: Hong Xu <hong@topbug.net>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
Add hook mechanism.
---
editorconfig.el | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/editorconfig.el b/editorconfig.el
index baeb8350cf..c09496a74a 100644
--- a/editorconfig.el
+++ b/editorconfig.el
@@ -50,6 +50,27 @@
:type 'string
:group 'editorconfig)
+(defcustom edconf-custom-hooks ()
+ "A list of custom hooks after loading common EditorConfig settings
+
+Each element in this list is a hook function. This hook function takes one
+parameter, which is a property hash table. The value of properties can be
+obtained through gethash function.
+
+The hook does not have to be coding style related; you can add whatever
+functionality you want. For example, the following is an example to add a new
+property emacs_linum to decide whether to show line numbers on the left
+
+(add-to-list 'edconf-custom-hooks
+ '(lambda (props)
+ (let ((show-line-num (gethash 'emacs_linum props)))
+ (cond ((equal show-line-num \"true\") (linum-mode 1))
+ ((equal show-line-num \"false\") (linum-mode 0))))))
+
+"
+ :type '(lambda (properties) (body))
+ :group 'editorconfig)
+
(defun edconf-string-integer-p (string)
"Whether a string representing integer"
(if (stringp string)
@@ -90,6 +111,8 @@
)
(defun edconf-find-file-hook ()
- (edconf-set-line-length (gethash 'max_line_length props)))
+ (edconf-set-line-length (gethash 'max_line_length props))
+ (dolist (hook edconf-custom-hooks)
+ (funcall hook props)))
(provide 'editorconfig)
- [nongnu] scratch/editorconfig-cc 4beeb9c830 253/351: Make editorconfig-properties-hash permanetn-local, (continued)
- [nongnu] scratch/editorconfig-cc 4beeb9c830 253/351: Make editorconfig-properties-hash permanetn-local, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc ee5b70f1e2 068/351: editorocnfig-core: Throw error when parsing .editorconfig failed, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 3bdd68d5af 069/351: Add tcl-mode indentation support, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 32fb0d6b9c 056/351: Use `require` instead of `load` in usage example, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 903e483a70 052/351: Make `editorconfig-apply' an interactive command, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 4fd932bb7c 060/351: Check package metadata using ert framework, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 56722d34df 019/351: Add sh-indentation to the list of indent variable., Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 92519a8c25 022/351: Don't set indent size if the given value makes no sense., Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 242cc0ccea 045/351: Use core in elisp as a fallback, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc b1643c7360 077/351: Add support for scss-mode, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc e7a0874591 026/351: Add hook mechanism.,
Stefan Monnier <=
- [nongnu] scratch/editorconfig-cc c02d94298b 082/351: Add editorocnfig-display-current-properties, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc e452e1d45b 086/351: Bump version to 0.7.4, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 1eabf1ce45 110/351: Add link to Melpa stable, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 0057f62085 103/351: Bump version to 0.7.5, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc c9b5e73d1d 138/351: Add support for verilog-mode, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc aa57926fdf 163/351: docs -> doc, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc f2c8300dba 129/351: Add Usami Kenta to the contributor list., Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc d7c6a8befd 128/351: Reidentation for all *.el files., Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 8a2e9be119 131/351: Fix indentations of ert-tests/, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 20c8ea8cc9 174/351: Update travis config file, Stefan Monnier, 2024/06/13