[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] scratch/editorconfig-cc 21ea6f23c2 063/351: Support charset pro
From: |
Stefan Monnier |
Subject: |
[nongnu] scratch/editorconfig-cc 21ea6f23c2 063/351: Support charset property |
Date: |
Thu, 13 Jun 2024 18:38:41 -0400 (EDT) |
branch: scratch/editorconfig-cc
commit 21ea6f23c2e9629dcb45e67a91a5326782464dd9
Author: 10sr <8slashes+git@gmail.com>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
Support charset property
---
editorconfig.el | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/editorconfig.el b/editorconfig.el
index 9a7be9c969..897ea7e909 100644
--- a/editorconfig.el
+++ b/editorconfig.el
@@ -193,9 +193,25 @@ NOTE: Only the **buffer local** value of VARIABLE will be
set."
(when (not (equal size "tab")) (setq size nil)))
)
-(defun editorconfig-set-line-ending (end-of-line)
- "Set line ending style to CR, LF, or CRLF by END-OF-LINE."
- )
+(defun editorconfig-set-coding-system (end-of-line charset)
+ "Set buffer coding system by END-OF-LINE and CHARSET."
+ (let ((eol (cond
+ ((equal end-of-line "lf") 'undecided-unix)
+ ((equal end-of-line "cr") 'undecided-mac)
+ ((equal end-of-line "crlf") 'undecided-dos)
+ (t 'undecided)))
+ (cs (cond
+ ((equal charset "latin1") 'iso-latin-1)
+ ((equal charset "utf-8") 'utf-8)
+ ((equal charset "utf-8-bom") 'utf-8-with-signature)
+ ((equal charset "utf-16be") 'utf-16be)
+ ((equal charset "utf-16le") 'utf-16le)
+ (t 'undecided))))
+ (set-buffer-file-coding-system (merge-coding-systems
+ cs
+ eol)
+ nil t)))
+
(defun editorconfig-set-line-length (length)
"Set the max line length (fill-column) to LENGTH."
@@ -234,6 +250,9 @@ It calls `editorconfig-get-properties-from-exec' if
(funcall editorconfig-get-properties-function))))
(if props
(progn
+ (editorconfig-set-coding-system
+ (gethash 'end_of_line props)
+ (gethash 'charset props))
(editorconfig-set-line-length (gethash 'max_line_length props))
(run-hook-with-args 'editorconfig-custom-hooks props))
(display-warning :error "EditorConfig core program is not available.
Styles will not be applied.")))))
- [nongnu] scratch/editorconfig-cc ebd09d700f 047/351: Fix all indentation according to editorconfig, (continued)
- [nongnu] scratch/editorconfig-cc ebd09d700f 047/351: Fix all indentation according to editorconfig, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 381cf75a95 070/351: Add ps-mode indentation support, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc aea1b70fa7 066/351: I forgot to update editorconfig-core-version const, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 98999896aa 078/351: Add octave-mode and matlab-mode support, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc c36ed4aeb7 025/351: Version 0.4, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 0efb6ea02f 039/351: Add 10sr to the contributor list, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 16bd394d1f 036/351: Add aliases for obsolete variables and bump version, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc d7a42c819c 043/351: Add editorconfig-core el files, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 46eb2863da 031/351: Add autoload cookie, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 0b31539954 072/351: Throw error when editorconfig executable was not found, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 21ea6f23c2 063/351: Support charset property,
Stefan Monnier <=
- [nongnu] scratch/editorconfig-cc 2ddf470e7b 062/351: Bump version: 0.6.2, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 9d1d236431 021/351: Don't set max_line_length if not specified., Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc fbe97a0824 014/351: Wrong way to indent html. Fixes it., Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc d1ea0124c5 040/351: Do nothing when current buffer does not visit any file, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 0a319fab78 033/351: Add global minor mode, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc b08e13aefa 042/351: Add files used to test core functions, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc d776cdc5ee 020/351: Support max_line_length., Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc d83aba5206 055/351: Bump version: 0.6.1, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc b4911d662f 075/351: Already 2016 :) Happy new year!, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 75139b95da 059/351: Use dedicated functions to manipulate hook, Stefan Monnier, 2024/06/13