aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2024-06-17 10:41:31 -0400
committerStefan Monnier2024-06-19 14:38:31 -0400
commit3f90253dae0eda0ff2fa0b2635dc8e9b6a300641 (patch)
tree103d7f9d42549be2a0d8a225fa0839a0c9bf85ba
parent729fc9b88b44f4168a842b3d38bc5b4be3c25772 (diff)
downloademacs-3f90253dae0eda0ff2fa0b2635dc8e9b6a300641.tar.gz
emacs-3f90253dae0eda0ff2fa0b2635dc8e9b6a300641.zip
Remove support for the `editorconfig` executable
Some of the code lacks copyright paperwork, so let's remove it for now, so we don't have to adapt it to the new hooks. If/when it proves useful/necessary it'll be easy enough to re-add. * editorconfig.el (editorconfig-exec-path, edconf-get-properties-function) (edconf-exec-path, editorconfig-get-properties-function): Delete variables. (editorconfig--execute-editorconfig-exec) (editorconfig--parse-properties, editorconfig-get-properties) (editorconfig-get-properties-from-exec): Delete functions. (editorconfig-call-get-properties-function): Call `editorconfig-core-get-properties-hash` directly.
-rw-r--r--lisp/editorconfig.el109
1 files changed, 3 insertions, 106 deletions
diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el
index 4a873ce84db..5c74e35fc52 100644
--- a/lisp/editorconfig.el
+++ b/lisp/editorconfig.el
@@ -65,52 +65,6 @@ coding styles between different editors and IDEs."
65 :group 'tools) 65 :group 'tools)
66 66
67(define-obsolete-variable-alias 67(define-obsolete-variable-alias
68 'edconf-exec-path
69 'editorconfig-exec-path
70 "0.5")
71(defcustom editorconfig-exec-path
72 "editorconfig"
73 "Path to EditorConfig executable.
74
75Used by `editorconfig--execute-editorconfig-exec'."
76 :type 'string
77 :group 'editorconfig)
78
79(define-obsolete-variable-alias
80 'edconf-get-properties-function
81 'editorconfig-get-properties-function
82 "0.5")
83(defcustom editorconfig-get-properties-function
84 'editorconfig-core-get-properties-hash
85 "A function which gets EditorConfig properties for specified file.
86
87This function will be called with one argument, full path of the target file,
88and should return a hash object containing properties, or nil if any core
89program is not available. Keys of this hash should be symbols of properties,
90and values should be strings of their values.
91
92
93For example, if you always want to use built-in core library instead
94of any EditorConfig executable to get properties, add following to
95your init.el:
96
97 (set-variable \\='editorconfig-get-properties-function
98 #\\='editorconfig-core-get-properties-hash)
99
100Possible known values are:
101
102* `editorconfig-core-get-properties-hash' (default)
103 * Always use built-in Emacs-Lisp implementation to get properties
104* `editorconfig-get-properties'
105 * Use `editorconfig-get-properties-from-exec' when
106 `editorconfig-exec-path' executable is found, otherwise
107 use `editorconfig-core-get-properties-hash'
108* `editorconfig-get-properties-from-exec'
109 * Get properties by executing EditorConfig executable"
110 :type 'function
111 :group 'editorconfig)
112
113(define-obsolete-variable-alias
114 'edconf-custom-hooks 68 'edconf-custom-hooks
115 'editorconfig-after-apply-functions 69 'editorconfig-after-apply-functions
116 "0.5") 70 "0.5")
@@ -462,76 +416,19 @@ to non-nil when FINAL-NEWLINE is true."
462 (> (string-to-number length) 0)) 416 (> (string-to-number length) 0))
463 (setq fill-column (string-to-number length)))) 417 (setq fill-column (string-to-number length))))
464 418
465
466(defun editorconfig--execute-editorconfig-exec (filename)
467 "Execute EditorConfig core with FILENAME and return output."
468 (if filename
469 (with-temp-buffer
470 (let ((remote (file-remote-p filename))
471 (remote-localname (file-remote-p filename
472 'localname)))
473 (display-warning '(editorconfig editorconfig--execute-editorconfig-exec)
474 (format "editorconfig--execute-editorconfig-exec: filename: %S | remote: %S | remote-localname: %S"
475 filename
476 remote
477 remote-localname)
478 :debug)
479 (if remote
480 (progn
481 (cd (concat remote "/"))
482 (setq filename remote-localname))
483 (cd "/")))
484 (display-warning '(editorconfig editorconfig--execute-editorconfig-exec)
485 (format "editorconfig--execute-editorconfig-exec: default-directory: %S | filename: %S"
486 default-directory
487 filename
488 )
489 :debug)
490 (if (eq 0
491 (process-file editorconfig-exec-path nil t nil filename))
492 (buffer-string)
493 (editorconfig-error (buffer-string))))
494 ""))
495
496(defun editorconfig--parse-properties (props-string)
497 )
498
499(defun editorconfig-get-properties-from-exec (filename)
500 "Get EditorConfig properties of file FILENAME.
501
502This function uses value of `editorconfig-exec-path' to get properties."
503 (if (executable-find editorconfig-exec-path)
504 (editorconfig--parse-properties (editorconfig--execute-editorconfig-exec filename))
505 (editorconfig-error "Unable to find editorconfig executable")))
506
507(defun editorconfig-get-properties (filename)
508 "Get EditorConfig properties for file FILENAME.
509
510It calls `editorconfig-get-properties-from-exec' if
511`editorconfig-exec-path' is found, otherwise
512`editorconfig-core-get-properties-hash'."
513 (if (and (executable-find editorconfig-exec-path)
514 (not (file-remote-p filename)))
515 (editorconfig-get-properties-from-exec filename)
516 (require 'editorconfig-core)
517 (editorconfig-core-get-properties-hash filename)))
518
519(defun editorconfig-call-get-properties-function (filename) 419(defun editorconfig-call-get-properties-function (filename)
520 "Call `editorconfig-get-properties-function' with FILENAME and return result. 420 "Call `editorconfig-core-get-properties-hash' with FILENAME and return result.
521 421
522This function also removes `unset' properties and calls 422This function also removes `unset' properties and calls
523`editorconfig-hack-properties-functions'." 423`editorconfig-hack-properties-functions'."
524 (unless (functionp editorconfig-get-properties-function)
525 (editorconfig-error "Invalid editorconfig-get-properties-function value"))
526 (if (stringp filename) 424 (if (stringp filename)
527 (setq filename (expand-file-name filename)) 425 (setq filename (expand-file-name filename))
528 (editorconfig-error "Invalid argument: %S" filename)) 426 (editorconfig-error "Invalid argument: %S" filename))
529 (let ((props nil)) 427 (let ((props nil))
530 (condition-case err 428 (condition-case err
531 (setq props (funcall editorconfig-get-properties-function 429 (setq props (editorconfig-core-get-properties-hash filename))
532 filename))
533 (error 430 (error
534 (editorconfig-error "Error from editorconfig-get-properties-function: %S" 431 (editorconfig-error "Error from editorconfig-core-get-properties-hash: %S"
535 err))) 432 err)))
536 (cl-loop for k being the hash-keys of props using (hash-values v) 433 (cl-loop for k being the hash-keys of props using (hash-values v)
537 when (equal v "unset") do (remhash k props)) 434 when (equal v "unset") do (remhash k props))