branch: scratch/editorconfig-cc
commit bc99704785df68a153faf1b5296e33ee244f4831
Author: USAMI Kenta <tad...@zonu.me>
Commit: Stefan Monnier <monn...@iro.umontreal.ca>

    Add editorconfig-exclude-prefixes (#108)
---
 editorconfig.el | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/editorconfig.el b/editorconfig.el
index f4ad969615..36da23ed2f 100644
--- a/editorconfig.el
+++ b/editorconfig.el
@@ -38,6 +38,8 @@
 ;; version control systems.
 
 ;;; Code:
+(require 'cl-lib)
+(eval-when-compile (require 'rx))
 
 (declare-function editorconfig-core-get-properties-hash
                   "editorconfig-core"
@@ -194,6 +196,13 @@ NOTE: Only the **buffer local** value of VARIABLE will be 
set."
   :type '(repeat (symbol :tag "Major Mode"))
   :group 'editorconfig)
 
+(defcustom editorconfig-exclude-regexps
+  (list (eval-when-compile
+          (rx string-start (or "http" "https" "ftp" "sftp" "rsync") ":")))
+  "List of buffer filename prefix regexp patterns not to apply properties."
+  :type '(repeat string)
+  :group 'editorconfig)
+
 (defvar editorconfig-properties-hash nil
   "Hash object of EditorConfig properties for current buffer.
 Set by `editorconfig-apply' and nil if that is not invoked in current buffer
@@ -321,7 +330,11 @@ This function do the job only when the major mode is not 
listed in
 `editorconfig-exclude-modes'."
   (when (and major-mode
              (not (memq major-mode
-                        editorconfig-exclude-modes)))
+                        editorconfig-exclude-modes))
+             buffer-file-name
+             (not (cl-loop for regexp in editorconfig-exclude-regexps
+                           if (string-match regexp buffer-file-name) return t
+                           finally return nil)))
     (editorconfig-apply)))
 
 

Reply via email to