From unknown Sun Jun 22 20:58:12 2025 X-Loop: help-debbugs@gnu.org Subject: bug#27881: New major mode: Less mode Resent-From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 Jul 2017 17:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 27881 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 27881@debbugs.gnu.org Cc: Steve Purcell , Tom Tromey , Stefan Monnier , Dmitry Gutov X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.15014372169934 (code B ref -1); Sun, 30 Jul 2017 17:54:01 +0000 Received: (at submit) by debbugs.gnu.org; 30 Jul 2017 17:53:36 +0000 Received: from localhost ([127.0.0.1]:34502 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dbsPD-0002a6-OC for submit@debbugs.gnu.org; Sun, 30 Jul 2017 13:53:35 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45006) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dbsPB-0002Zt-FL for submit@debbugs.gnu.org; Sun, 30 Jul 2017 13:53:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dbsP3-0004qP-Az for submit@debbugs.gnu.org; Sun, 30 Jul 2017 13:53:24 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:37987) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dbsP3-0004px-6X for submit@debbugs.gnu.org; Sun, 30 Jul 2017 13:53:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dbsP0-0000Ke-6W for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2017 13:53:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dbsOw-0004lF-1o for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2017 13:53:18 -0400 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]:35381) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dbsOr-0004gT-Jn for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2017 13:53:13 -0400 Received: by mail-lf0-x243.google.com with SMTP id w199so10787252lff.2 for ; Sun, 30 Jul 2017 10:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:mime-version; bh=MJRyAqXX6fMkX94FuSbdK2pB2lVmwX5p2ZKu1jOaqoE=; b=etVju6Wg2B9GvyMAS1VeHN4UyjuNdjbZeq5iSsqregfNtgbZHfte7DCaLIxSWTe7vx A1uS6Aw63Lt6hAzvzfaWid1VjiuLDWnTNJGXIJjnqmzxqYMjqNy86Jnl7A5l/i34ftzr 0oZJzTv6eX/5LMuSVJFUw3C703J75S90dt6qo04CFDEnyN735RtHZlnjBwg3iI7w9yIh CBbPnsU53vIpO5wD2Z97IzoyhsWdXLSykawfF8+7O0xtZpQRtPDRJV5EQadgHy/E6AhT wcY9eFcYn9+R4WrnDB2IPWJFn/7kAA2Mt5bekmn2j3Me4yQhZsW/LxZRkc+ffE8lE8b4 DBmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:mime-version; bh=MJRyAqXX6fMkX94FuSbdK2pB2lVmwX5p2ZKu1jOaqoE=; b=XbqWIMgxzKy8vk8mhhUtPnxp4oLS//5uBtiaMVd4JJK7nuMsBSNMfL9immGONARZl/ M4wa7JWWqKM/kXAgExyvqDe4u8hyVd+DhbqlTxBPBuXkNURjay2mhq6H6MVVGa+70r2J f0wduSrqgSPQSAwgCannyMnH0CTbfIafnjjtvO1zxH+exdfdVOYM1b32FNM0eVq2BdeU 1uZMyiMAA83YZQ1oAeqte5fPKack5RHL//0h8Mg6kzaHZJKJ0fEHRDjsOWvcA8anIJR+ nz4cjFiHEuv34HfK43C/pWw5gG5Ev55DWyRuDk0qLjJVrV/AX0rmG92rQXBtuE0tqOyp +kKw== X-Gm-Message-State: AIVw113lrxg1ee5p2xsyftDSZg3xITuFSz3k+VXQhUgeYsRDtuEIiz4c m2yTPMRbJ1/Rd3mI X-Received: by 10.25.199.77 with SMTP id x74mr4515810lff.196.1501437186053; Sun, 30 Jul 2017 10:53:06 -0700 (PDT) Received: from [192.168.100.10] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id m5sm5030493lfm.82.2017.07.30.10.53.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 30 Jul 2017 10:53:05 -0700 (PDT) Date: Sun, 30 Jul 2017 19:53:03 +0200 From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Message-Id: <1501437183.13205.0@smtp.gmail.com> X-Mailer: geary/0.11.3 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-p4GrjrrZxOwb/2G34Bou" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --=-p4GrjrrZxOwb/2G34Bou Content-Type: text/plain; charset=utf-8; format=flowed Hi. Steve Purcell has developed a very nice major mode for editing Less files (a minor variant of CSS). Seeing that Emacs' built-in CSS mode got extended to support SCSS (another minor CSS variant) three years ago, I contacted Steve and asked if he'd like Less mode to become a part of Emacs as well, which he agreed to. I've attached two patches which merge Steve's Less mode into css-mode.el. The first patch is a verbatim copy of Steve's code, the second one contains minor cleanups made by me. The biggest change I've made is to rename the mode from "Less CSS mode" to just "Less mode". I think the renaming has two advantages: Aligning its name with "SCSS mode", and making the mode's commands, variables and function names shorter. The downside is that existing users of Less mode will have to update their config files. Maybe aliasing `less-css-mode' to `less-mode' could help some in that regard. What do you think of it? If this looks okay, I'll complete the patches (fix the commit messages and make a NEWS entry), install them, and start maintaining Less mode as part of css-mode.el. -- Simen --=-p4GrjrrZxOwb/2G34Bou Content-Type: multipart/mixed; boundary="=-d1bLGzGfoMm57wbQ/H2A" --=-d1bLGzGfoMm57wbQ/H2A Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-WIP-New-major-mode-Less-mode-a-minor-variant-of-CSS.patch >From 343b15f8c95ccbd935b5b715b8127d16bd4d7e84 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 12 Jun 2017 22:06:46 +0200 Subject: [PATCH 1/2] WIP: New major mode: Less mode (a minor variant of CSS) --- lisp/textmodes/css-mode.el | 228 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 227 insertions(+), 1 deletion(-) diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 19cb7b4fea..c1ed44b984 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -32,9 +32,10 @@ ;;; Code: -(require 'eww) (require 'cl-lib) (require 'color) +(require 'compile) +(require 'eww) (require 'seq) (require 'sgml-mode) (require 'smie) @@ -1558,6 +1559,231 @@ scss-mode +;;; Less mode +;; +;; This mode provides syntax highlighting for LESS CSS files, plus +;; optional support for compilation of .less files to .css files at +;; the time they are saved: use `less-css-compile-at-save' to enable +;; this. +;; +;; Command line utility "lessc" is required if setting +;; `less-css-compile-at-save' to t. To install "lessc" using the +;; Node.js package manager, run "npm install less" +;; +;; Also make sure the "lessc" executable is in Emacs' PATH, example: +;; (setq exec-path (cons (expand-file-name "~/.gem/ruby/1.8/bin") exec-path)) +;; or customize `less-css-lessc-command' to point to your "lessc" +;; executable. +;; +;; We target lessc >= 1.4.0, and thus use the `--no-color' flag by +;; default. You may want to adjust `less-css-lessc-options' for +;; compatibility with older versions. +;; +;; `less-css-mode' is derived from `css-mode', and indentation of +;; nested blocks may not work correctly with versions of `css-mode' +;; other than that bundled with recent Emacs. +;; +;; You can specify per-file values for `less-css-compile-at-save', +;; `less-css-output-file-name' or `less-css-output-directory' using a +;; variables header at the top of your .less file, e.g.: +;; +;; // -*- less-css-compile-at-save: t; less-css-output-directory: "../css" -*- +;; +;; Alternatively, you can use directory local variables to set the +;; default value of `less-css-output-directory' for your project. +;; +;; In the case of files which are included in other .less files, you +;; may want to trigger the compilation of a "master" .less file on +;; save: you can accomplish this with `less-css-input-file-name', +;; which is probably best set using directory local variables. +;; +;; If you don't need CSS output but would like to be warned of any +;; syntax errors in your .less source, consider using `flymake-less': +;; https://github.com/purcell/flymake-less +;; +;;; Credits +;; +;; The original code for this mode was, in large part, written using +;; Anton Johansson's scss-mode as a template -- thanks Anton! +;; https://github.com/antonj + +(defgroup less-css nil + "Less-css mode" + :prefix "less-css-" + :group 'css) + +;;;###autoload +(defcustom less-css-lessc-command "lessc" + "Command used to compile LESS files. +Should be lessc or the complete path to your lessc executable, + e.g.: \"~/.gem/ruby/1.8/bin/lessc\"" + :type 'file + :group 'less-css + :safe 'stringp) + +;;;###autoload +(defcustom less-css-compile-at-save nil + "If non-nil, the LESS buffers will be compiled to CSS after each save." + :type 'boolean + :group 'less-css + :safe 'booleanp) + +;;;###autoload +(defcustom less-css-lessc-options '("--no-color") + "Command line options for less executable. + +Use \"-x\" to minify output." + :type '(repeat string) + :group 'less-css + :safe t) + +;;;###autoload +(defcustom less-css-output-directory nil + "Directory in which to save CSS, or nil to use the LESS file's directory. + +This path is expanded relative to the directory of the LESS file +using `expand-file-name', so both relative and absolute paths +will work as expected." + :type 'directory + :group 'less-css + :safe 'stringp) + +;;;###autoload +(defcustom less-css-output-file-name nil + "File name in which to save CSS, or nil to use .css for .less. + +This can be also be set to a full path, or a relative path. If +the path is relative, it will be relative to the value of +`less-css-output-dir', if set, or the current directory by +default." + :type 'file + :group 'less-css + :safe 'stringp) +(make-variable-buffer-local 'less-css-output-file-name) + +;;;###autoload +(defcustom less-css-input-file-name nil + "File name which will be compiled to CSS. + +When the current buffer is saved `less-css-input-file-name' file +will be compiled to css instead of the current file. + +Set this in order to trigger compilation of a \"master\" .less +file which includes the current file. The best way to set this +variable in most cases is likely to be via directory local +variables. + +This can be also be set to a full path, or a relative path. If +the path is relative, it will be relative to the the current directory by +default." + :type 'file + :group 'less-css + :safe 'stringp) +(make-variable-buffer-local 'less-css-input-file-name) + +(defconst less-css-default-error-regex + "^\\(?:\e\\[31m\\)?\\([^\e\n]*\\|FileError:.*\n\\)\\(?:\e\\[39m\e\\[31m\\)? in \\(?:\e\\[39m\\)?\\([^ \r\n\t\e]+\\)\\(?:\e\\[90m\\)?\\(?::\\| on line \\)\\([0-9]+\\)\\(?::\\|, column \\)\\([0-9]+\\):?\\(?:\e\\[39m\\)?") + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Compilation to CSS +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(add-to-list 'compilation-error-regexp-alist-alist + (list 'less-css less-css-default-error-regex 2 3 4 nil 1)) +(add-to-list 'compilation-error-regexp-alist 'less-css) + + +(defun less-css-compile-maybe () + "Run `less-css-compile' if `less-css-compile-at-save' is non-nil." + (if less-css-compile-at-save + (less-css-compile))) + +(defun less-css--output-path () + "Calculate the path for the compiled CSS file created by `less-css-compile'." + (expand-file-name (or less-css-output-file-name + (concat (file-name-nondirectory (file-name-sans-extension buffer-file-name)) ".css")) + (or less-css-output-directory default-directory))) + +(defun less-css--maybe-shell-quote-command (command) + "Selectively shell-quote COMMAND appropriately for `system-type'." + (funcall (if (eq system-type 'windows-nt) + 'identity + 'shell-quote-argument) command)) + +;;;###autoload +(defun less-css-compile () + "Compiles the current buffer to css using `less-css-lessc-command'." + (interactive) + (message "Compiling less to css") + (let ((compilation-buffer-name-function (lambda (mode-name) "*less-css-compilation*"))) + (save-window-excursion + (with-current-buffer + (compile + (mapconcat 'identity + (append (list (less-css--maybe-shell-quote-command less-css-lessc-command)) + (mapcar 'shell-quote-argument less-css-lessc-options) + (list (shell-quote-argument + (or less-css-input-file-name buffer-file-name)) + (shell-quote-argument (less-css--output-path)))) + " ")) + (add-hook 'compilation-finish-functions + (lambda (buf msg) + (unless (string-match-p "^finished" msg) + (display-buffer buf))) + nil + t))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Minor mode +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; TODO: interpolation ("@{val}"), escaped values (~"..."), JS eval (~`...`), custom faces +(defconst less-css-font-lock-keywords + '(;; Variables + ("@[a-z_-][a-z-_0-9]*" . font-lock-constant-face) + ("&" . font-lock-preprocessor-face) + ;; Mixins + ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" . (1 font-lock-keyword-face))) + ) + +;;;###autoload +(define-derived-mode less-css-mode css-mode "LESS" + "Major mode for editing LESS files, http://lesscss.org/ +Special commands: +\\{less-css-mode-map}" + (font-lock-add-keywords nil less-css-font-lock-keywords) + ;; cpp-style comments + (modify-syntax-entry ?/ ". 124b" less-css-mode-syntax-table) + (modify-syntax-entry ?* ". 23" less-css-mode-syntax-table) + (modify-syntax-entry ?\n "> b" less-css-mode-syntax-table) + ;; Special chars that sometimes come at the beginning of words. + (modify-syntax-entry ?. "'" less-css-mode-syntax-table) + + (set (make-local-variable 'comment-start) "//") + (set (make-local-variable 'comment-end) "") + (set (make-local-variable 'indent-line-function) 'less-css-indent-line) + (when (functionp 'css-smie-rules) + (smie-setup css-smie-grammar #'css-smie-rules + :forward-token #'css-smie--forward-token + :backward-token #'css-smie--backward-token)) + + (add-hook 'after-save-hook 'less-css-compile-maybe nil t)) + +(define-key less-css-mode-map "\C-c\C-c" 'less-css-compile) + +(defun less-css-indent-line () + "Indent current line according to LESS CSS indentation rules." + (let ((css-navigation-syntax-table less-css-mode-syntax-table)) + (if (fboundp 'css-indent-line) + (css-indent-line) + (smie-indent-line)))) + +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.less\\'" . less-css-mode)) + + + (defvar css--mdn-lookup-history nil) (defcustom css-lookup-url-format -- 2.13.2 --=-d1bLGzGfoMm57wbQ/H2A Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-WIP-Fixes-and-tweaks-for-the-new-Less-mode.patch >From 30d4e2a4b5bb80765e2efa0ef9eba547cc079f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= Date: Mon, 12 Jun 2017 22:15:51 +0200 Subject: [PATCH 2/2] WIP: Fixes and tweaks for the new Less mode --- lisp/textmodes/css-mode.el | 232 +++++++++++++++++++++------------------------ 1 file changed, 109 insertions(+), 123 deletions(-) diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index c1ed44b984..67b786622b 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1561,41 +1561,42 @@ scss-mode ;;; Less mode ;; +;; Originally authored by Steve Purcell. +;; ;; This mode provides syntax highlighting for LESS CSS files, plus ;; optional support for compilation of .less files to .css files at -;; the time they are saved: use `less-css-compile-at-save' to enable -;; this. +;; the time they are saved: use `less-compile-at-save' to enable this. ;; ;; Command line utility "lessc" is required if setting -;; `less-css-compile-at-save' to t. To install "lessc" using the -;; Node.js package manager, run "npm install less" +;; `less-compile-at-save' to t. To install "lessc" using the Node.js +;; package manager, run "npm install less". ;; ;; Also make sure the "lessc" executable is in Emacs' PATH, example: -;; (setq exec-path (cons (expand-file-name "~/.gem/ruby/1.8/bin") exec-path)) -;; or customize `less-css-lessc-command' to point to your "lessc" -;; executable. +;; (setq exec-path (cons (expand-file-name "~/.gem/ruby/1.8/bin") +;; exec-path)) or customize `less-lessc-command' to point to your +;; "lessc" executable. ;; ;; We target lessc >= 1.4.0, and thus use the `--no-color' flag by -;; default. You may want to adjust `less-css-lessc-options' for +;; default. You may want to adjust `less-lessc-options' for ;; compatibility with older versions. ;; -;; `less-css-mode' is derived from `css-mode', and indentation of -;; nested blocks may not work correctly with versions of `css-mode' -;; other than that bundled with recent Emacs. +;; `less-mode' is derived from `css-mode', and indentation of nested +;; blocks may not work correctly with versions of `css-mode' other +;; than that bundled with recent Emacs. ;; -;; You can specify per-file values for `less-css-compile-at-save', -;; `less-css-output-file-name' or `less-css-output-directory' using a +;; You can specify per-file values for `less-compile-at-save', +;; `less-output-file-name' or `less-output-directory' using a ;; variables header at the top of your .less file, e.g.: ;; -;; // -*- less-css-compile-at-save: t; less-css-output-directory: "../css" -*- +;; // -*- less-compile-at-save: t; less-output-directory: "../css" -*- ;; ;; Alternatively, you can use directory local variables to set the -;; default value of `less-css-output-directory' for your project. +;; default value of `less-output-directory' for your project. ;; ;; In the case of files which are included in other .less files, you ;; may want to trigger the compilation of a "master" .less file on -;; save: you can accomplish this with `less-css-input-file-name', -;; which is probably best set using directory local variables. +;; save: you can accomplish this with `less-input-file-name', which is +;; probably best set using directory local variables. ;; ;; If you don't need CSS output but would like to be warned of any ;; syntax errors in your .less source, consider using `flymake-less': @@ -1607,66 +1608,61 @@ scss-mode ;; Anton Johansson's scss-mode as a template -- thanks Anton! ;; https://github.com/antonj -(defgroup less-css nil - "Less-css mode" - :prefix "less-css-" +(defgroup less nil + "Less CSS mode" + :prefix "less-" :group 'css) ;;;###autoload -(defcustom less-css-lessc-command "lessc" - "Command used to compile LESS files. -Should be lessc or the complete path to your lessc executable, - e.g.: \"~/.gem/ruby/1.8/bin/lessc\"" +(defcustom less-lessc-command "lessc" + "Command used to compile Less files. +Should be \"lessc\" or the complete path to your lessc executable, +e.g.: \"~/.gem/ruby/1.8/bin/lessc\"." :type 'file - :group 'less-css + :group 'less :safe 'stringp) ;;;###autoload -(defcustom less-css-compile-at-save nil - "If non-nil, the LESS buffers will be compiled to CSS after each save." +(defcustom less-compile-at-save nil + "If non-nil, Less buffers are compiled to CSS after each save." :type 'boolean - :group 'less-css + :group 'less :safe 'booleanp) ;;;###autoload -(defcustom less-css-lessc-options '("--no-color") - "Command line options for less executable. - +(defcustom less-lessc-options '("--no-color") + "Command line options for Less executable. Use \"-x\" to minify output." :type '(repeat string) - :group 'less-css + :group 'less :safe t) ;;;###autoload -(defcustom less-css-output-directory nil - "Directory in which to save CSS, or nil to use the LESS file's directory. - -This path is expanded relative to the directory of the LESS file +(defcustom less-output-directory nil + "Directory in which to save CSS, or nil to use the Less file's directory. +This path is expanded relative to the directory of the Less file using `expand-file-name', so both relative and absolute paths will work as expected." :type 'directory - :group 'less-css + :group 'less :safe 'stringp) ;;;###autoload -(defcustom less-css-output-file-name nil +(defcustom less-output-file-name nil "File name in which to save CSS, or nil to use .css for .less. - This can be also be set to a full path, or a relative path. If the path is relative, it will be relative to the value of -`less-css-output-dir', if set, or the current directory by -default." +`less-output-dir', if set, or the current directory by default." :type 'file - :group 'less-css + :group 'less :safe 'stringp) -(make-variable-buffer-local 'less-css-output-file-name) +(make-variable-buffer-local 'less-output-file-name) ;;;###autoload -(defcustom less-css-input-file-name nil +(defcustom less-input-file-name nil "File name which will be compiled to CSS. - -When the current buffer is saved `less-css-input-file-name' file -will be compiled to css instead of the current file. +When the current buffer is saved `less-input-file-name' file will +be compiled to CSS instead of the current file. Set this in order to trigger compilation of a \"master\" .less file which includes the current file. The best way to set this @@ -1674,59 +1670,61 @@ less-css-input-file-name variables. This can be also be set to a full path, or a relative path. If -the path is relative, it will be relative to the the current directory by -default." +the path is relative, it will be relative to the the current +directory by default." :type 'file - :group 'less-css + :group 'less :safe 'stringp) -(make-variable-buffer-local 'less-css-input-file-name) +(make-variable-buffer-local 'less-input-file-name) -(defconst less-css-default-error-regex +(defconst less-default-error-regex "^\\(?:\e\\[31m\\)?\\([^\e\n]*\\|FileError:.*\n\\)\\(?:\e\\[39m\e\\[31m\\)? in \\(?:\e\\[39m\\)?\\([^ \r\n\t\e]+\\)\\(?:\e\\[90m\\)?\\(?::\\| on line \\)\\([0-9]+\\)\\(?::\\|, column \\)\\([0-9]+\\):?\\(?:\e\\[39m\\)?") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Compilation to CSS -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (add-to-list 'compilation-error-regexp-alist-alist - (list 'less-css less-css-default-error-regex 2 3 4 nil 1)) -(add-to-list 'compilation-error-regexp-alist 'less-css) - - -(defun less-css-compile-maybe () - "Run `less-css-compile' if `less-css-compile-at-save' is non-nil." - (if less-css-compile-at-save - (less-css-compile))) - -(defun less-css--output-path () - "Calculate the path for the compiled CSS file created by `less-css-compile'." - (expand-file-name (or less-css-output-file-name - (concat (file-name-nondirectory (file-name-sans-extension buffer-file-name)) ".css")) - (or less-css-output-directory default-directory))) - -(defun less-css--maybe-shell-quote-command (command) + (list 'less less-default-error-regex 2 3 4 nil 1)) +(add-to-list 'compilation-error-regexp-alist 'less) + +(defun less-compile-maybe () + "Run `less-compile' if `less-compile-at-save' is non-nil." + (when less-compile-at-save + (less-compile))) + +(defun less--output-path () + "Return the path to use for the compiled CSS file." + (expand-file-name + (or less-output-file-name + (concat + (file-name-nondirectory + (file-name-sans-extension buffer-file-name)) + ".css")) + (or less-output-directory default-directory))) + +(defun less--maybe-shell-quote-command (command) "Selectively shell-quote COMMAND appropriately for `system-type'." (funcall (if (eq system-type 'windows-nt) 'identity - 'shell-quote-argument) command)) + 'shell-quote-argument) + command)) ;;;###autoload -(defun less-css-compile () - "Compiles the current buffer to css using `less-css-lessc-command'." +(defun less-compile () + "Compile the current buffer to CSS using `less-lessc-command'." (interactive) - (message "Compiling less to css") - (let ((compilation-buffer-name-function (lambda (mode-name) "*less-css-compilation*"))) + (message "Compiling Less to CSS") + (let ((compilation-buffer-name-function + (lambda (_) "*less-compilation*"))) (save-window-excursion (with-current-buffer (compile - (mapconcat 'identity - (append (list (less-css--maybe-shell-quote-command less-css-lessc-command)) - (mapcar 'shell-quote-argument less-css-lessc-options) - (list (shell-quote-argument - (or less-css-input-file-name buffer-file-name)) - (shell-quote-argument (less-css--output-path)))) - " ")) + (string-join + (append (list (less--maybe-shell-quote-command less-lessc-command)) + (mapcar 'shell-quote-argument less-lessc-options) + (list (shell-quote-argument + (or less-input-file-name buffer-file-name)) + (shell-quote-argument (less--output-path)))) + " ")) (add-hook 'compilation-finish-functions (lambda (buf msg) (unless (string-match-p "^finished" msg) @@ -1734,53 +1732,41 @@ less-css-compile nil t))))) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Minor mode -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;; TODO: interpolation ("@{val}"), escaped values (~"..."), JS eval (~`...`), custom faces -(defconst less-css-font-lock-keywords +;; TODO: +;; - interpolation ("@{val}") +;; - escaped values (~"...") +;; - JavaScript eval (~`...`) +;; - custom faces +(defconst less-font-lock-keywords '(;; Variables - ("@[a-z_-][a-z-_0-9]*" . font-lock-constant-face) + ("@[a-z_-][a-z-_0-9]*" . font-lock-variable-name-face) ("&" . font-lock-preprocessor-face) ;; Mixins - ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" . (1 font-lock-keyword-face))) - ) + ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" . + (1 font-lock-keyword-face)))) + +(defvar less-mode-syntax-table + (let ((st (make-syntax-table css-mode-syntax-table))) + ;; C++-style comments. + (modify-syntax-entry ?/ ". 124b" st) + (modify-syntax-entry ?* ". 23" st) + (modify-syntax-entry ?\n "> b" st) + ;; Special chars that sometimes come at the beginning of words. + (modify-syntax-entry ?. "'" st) + st)) +;;;###autoload (add-to-list 'auto-mode-alist '("\\.less\\'" . less-mode)) ;;;###autoload -(define-derived-mode less-css-mode css-mode "LESS" - "Major mode for editing LESS files, http://lesscss.org/ +(define-derived-mode less-mode css-mode "Less" + "Major mode for editing Less files, http://lesscss.org/ Special commands: -\\{less-css-mode-map}" - (font-lock-add-keywords nil less-css-font-lock-keywords) - ;; cpp-style comments - (modify-syntax-entry ?/ ". 124b" less-css-mode-syntax-table) - (modify-syntax-entry ?* ". 23" less-css-mode-syntax-table) - (modify-syntax-entry ?\n "> b" less-css-mode-syntax-table) - ;; Special chars that sometimes come at the beginning of words. - (modify-syntax-entry ?. "'" less-css-mode-syntax-table) - - (set (make-local-variable 'comment-start) "//") - (set (make-local-variable 'comment-end) "") - (set (make-local-variable 'indent-line-function) 'less-css-indent-line) - (when (functionp 'css-smie-rules) - (smie-setup css-smie-grammar #'css-smie-rules - :forward-token #'css-smie--forward-token - :backward-token #'css-smie--backward-token)) - - (add-hook 'after-save-hook 'less-css-compile-maybe nil t)) - -(define-key less-css-mode-map "\C-c\C-c" 'less-css-compile) - -(defun less-css-indent-line () - "Indent current line according to LESS CSS indentation rules." - (let ((css-navigation-syntax-table less-css-mode-syntax-table)) - (if (fboundp 'css-indent-line) - (css-indent-line) - (smie-indent-line)))) +\\{less-mode-map}" + (font-lock-add-keywords nil less-font-lock-keywords) + (setq-local comment-start "//") + (setq-local comment-end "") + (add-hook 'after-save-hook 'less-compile-maybe nil t)) -;;;###autoload -(add-to-list 'auto-mode-alist '("\\.less\\'" . less-css-mode)) +(define-key less-mode-map "\C-c\C-c" 'less-compile) -- 2.13.2 --=-d1bLGzGfoMm57wbQ/H2A-- --=-p4GrjrrZxOwb/2G34Bou-- From unknown Sun Jun 22 20:58:12 2025 X-Loop: help-debbugs@gnu.org Subject: bug#27881: New major mode: Less mode Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 Jul 2017 22:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27881 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Cc: steve@sanityinc.com, 27881@debbugs.gnu.org, tom@tromey.com, dgutov@yandex.ru X-Debbugs-Original-Cc: Steve Purcell , bug-gnu-emacs@gnu.org, Tom Tromey , Dmitry Gutov Received: via spool by submit@debbugs.gnu.org id=B.15014533819314 (code B ref -1); Sun, 30 Jul 2017 22:23:02 +0000 Received: (at submit) by debbugs.gnu.org; 30 Jul 2017 22:23:01 +0000 Received: from localhost ([127.0.0.1]:34597 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dbwc1-0002Q9-1W for submit@debbugs.gnu.org; Sun, 30 Jul 2017 18:23:01 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33144) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dbwby-0002Pv-JM for submit@debbugs.gnu.org; Sun, 30 Jul 2017 18:22:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dbwbs-0003tc-HQ for submit@debbugs.gnu.org; Sun, 30 Jul 2017 18:22:53 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:54132) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dbwbs-0003tV-Di for submit@debbugs.gnu.org; Sun, 30 Jul 2017 18:22:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dbwbr-0002wn-8i for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2017 18:22:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dbwbo-0003rQ-1o for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2017 18:22:51 -0400 Received: from chicot.dit.umontreal.ca ([132.204.13.19]:47422) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dbwbn-0003qT-Ra for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2017 18:22:47 -0400 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id v6UL0CNi001985; Sun, 30 Jul 2017 17:00:37 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 5F8B366129; Sun, 30 Jul 2017 16:59:57 -0400 (EDT) From: Stefan Monnier Message-ID: References: <1501437183.13205.0@smtp.gmail.com> Date: Sun, 30 Jul 2017 16:59:57 -0400 In-Reply-To: <1501437183.13205.0@smtp.gmail.com> ("Simen =?UTF-8?Q?Heggest=C3=B8yl?="'s message of "Sun, 30 Jul 2017 19:53:03 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6082=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6082> : inlines <5998> : streams <1756466> : uri <2472980> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Thanks. Looks good. See some comments below. One thing, tho: an alternative would be to put it into its own file, which would give it more visibility Stefan > ;; This mode provides syntax highlighting for LESS CSS files, plus I'd add a URL pointing to the "canonical" place for Less. > -(defgroup less-css nil > - "Less-css mode" > - :prefix "less-css-" > +(defgroup less nil > + "Less CSS mode" > + :prefix "less-" > :group 'css) > ;;;###autoload > -(defcustom less-css-lessc-command "lessc" Why autoload all these defcustom. Sounds like a bug. > "File name in which to save CSS, or nil to use .css for .less. > - > This can be also be set to a full path, or a relative path. If > the path is relative, it will be relative to the value of > -`less-css-output-dir', if set, or the current directory by > -default." > +`less-output-dir', if set, or the current directory by default." > :type 'file > - :group 'less-css > + :group 'less > :safe 'stringp) Since these defcusotm come right after the (defgroup less ..), the :group 'less is redundant. > (add-to-list 'compilation-error-regexp-alist-alist > + (list 'less less-default-error-regex 2 3 4 nil 1)) BTW, I recommend reporting the use of an ad-hoc error format as an error to the Less developers. > ;;;###autoload > +(defun less-compile () Why autoload? This operates on the current buffer, so presumably this buffer is already in less-mode. > + (message "Compiling Less to CSS") I notice that "Less" is used pretty much everywhere except in the define-derived-mode where Steve used "LESS". Why not use "Less" in the mode name as well? > + (append (list (less--maybe-shell-quote-command less-lessc-command)) I'd recommend to just never quote less-lessc-command rather than only quote it on non-Windows systems. It's actually more flexible this way since less-lessc-command can then be set to something fancier (e.g. the command with a few flags). > +(defconst less-font-lock-keywords > '(;; Variables > - ("@[a-z_-][a-z-_0-9]*" . font-lock-constant-face) > + ("@[a-z_-][a-z-_0-9]*" . font-lock-variable-name-face) > ("&" . font-lock-preprocessor-face) > ;; Mixins > - ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" . (1 font-lock-keyword-face))) > - ) > + ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" . > + (1 font-lock-keyword-face)))) Is it important to limit those to ASCII chars? If not, then it's better to use [[:alpha:]_-] and [[:alnum:]_-] in the above regexps. > +(define-key less-mode-map "\C-c\C-c" 'less-compile) The standard way is to do: (defvar less-mode-map (let ((map (make-sparse-keymap)))) (define-key map "\C-c\C-c" 'less-compile) map) before the `define-derived-mode'. From unknown Sun Jun 22 20:58:12 2025 X-Loop: help-debbugs@gnu.org Subject: bug#27881: New major mode: Less mode Resent-From: Glenn Morris Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 31 Jul 2017 02:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27881 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Cc: Steve Purcell , Tom Tromey , Dmitry Gutov , 27881@debbugs.gnu.org, Stefan Monnier Received: via spool by 27881-submit@debbugs.gnu.org id=B27881.150146653528979 (code B ref 27881); Mon, 31 Jul 2017 02:03:02 +0000 Received: (at 27881) by debbugs.gnu.org; 31 Jul 2017 02:02:15 +0000 Received: from localhost ([127.0.0.1]:34676 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dc02A-0007XL-Sb for submit@debbugs.gnu.org; Sun, 30 Jul 2017 22:02:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40856) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dc029-0007Wx-MB for 27881@debbugs.gnu.org; Sun, 30 Jul 2017 22:02:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dc023-0002NZ-VV for 27881@debbugs.gnu.org; Sun, 30 Jul 2017 22:02:08 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:41522) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dc020-0002Jj-AC; Sun, 30 Jul 2017 22:02:04 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1dc01z-00014N-Qh; Sun, 30 Jul 2017 22:02:03 -0400 From: Glenn Morris References: <1501437183.13205.0@smtp.gmail.com> X-Spook: Bush Wired E. Coli 9705 Samford Road FEMA Conficker mania X-Ran: uL0R}NAXUe3?B+e+2~iZuD%tukAQW19"cA!=XPay,Eq>5Jjzu{)h/j0Ho/BP6'}3n3-Vtt X-Hue: magenta X-Attribution: GM Date: Sun, 30 Jul 2017 22:02:03 -0400 In-Reply-To: <1501437183.13205.0@smtp.gmail.com> ("Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Sun, 30 Jul 2017 19:53:03 +0200") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Simen Heggest=C3=B8yl wrote: > The biggest change I've made is to rename the mode from "Less CSS > mode" to just "Less mode". I think the renaming has two advantages: > Aligning its name with "SCSS mode", and making the mode's commands, > variables and function names shorter. The downside is that existing > users of Less mode will have to update their config files. Maybe > aliasing `less-css-mode' to `less-mode' could help some in that > regard. What do you think of it? FWIW, I would assume that "less-mode" was some sort of file viewer mode like the standalone less utility. From unknown Sun Jun 22 20:58:12 2025 X-Loop: help-debbugs@gnu.org Subject: bug#27881: New major mode: Less mode Resent-From: Marcin Borkowski Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 31 Jul 2017 04:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27881 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Glenn Morris Cc: Simen =?UTF-8?Q?Heggest=C3=B8yl?= , Dmitry Gutov , Steve Purcell , Tom Tromey , 27881@debbugs.gnu.org, Stefan Monnier Received: via spool by 27881-submit@debbugs.gnu.org id=B27881.150147557617210 (code B ref 27881); Mon, 31 Jul 2017 04:33:02 +0000 Received: (at 27881) by debbugs.gnu.org; 31 Jul 2017 04:32:56 +0000 Received: from localhost ([127.0.0.1]:34709 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dc2O0-0004TW-9D for submit@debbugs.gnu.org; Mon, 31 Jul 2017 00:32:56 -0400 Received: from mail.mojserwer.eu ([195.110.48.8]:53385) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dc2Ny-0004TM-ES for 27881@debbugs.gnu.org; Mon, 31 Jul 2017 00:32:55 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id 12C48E6AAD; Mon, 31 Jul 2017 06:32:52 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IITV75PzeoZb; Mon, 31 Jul 2017 06:32:49 +0200 (CEST) Received: from localhost (static-dwadziewiec-jedenpiec7.echostar.pl [109.232.29.157]) by mail.mojserwer.eu (Postfix) with ESMTPSA id 9D008E6AA8; Mon, 31 Jul 2017 06:32:48 +0200 (CEST) References: <1501437183.13205.0@smtp.gmail.com> User-agent: mu4e 0.9.19; emacs 26.0.50 From: Marcin Borkowski In-reply-to: Date: Mon, 31 Jul 2017 06:32:39 +0200 Message-ID: <8760e92plk.fsf@jane> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 2017-07-31, at 04:02, Glenn Morris wrote: > Simen Heggestøyl wrote: > >> The biggest change I've made is to rename the mode from "Less CSS >> mode" to just "Less mode". I think the renaming has two advantages: >> Aligning its name with "SCSS mode", and making the mode's commands, >> variables and function names shorter. The downside is that existing >> users of Less mode will have to update their config files. Maybe >> aliasing `less-css-mode' to `less-mode' could help some in that >> regard. What do you think of it? > > FWIW, I would assume that "less-mode" was some sort of file viewer mode > like the standalone less utility. Exactly my thought, I thought it is "view-mode on steroids"... -- Marcin Borkowski From unknown Sun Jun 22 20:58:12 2025 X-Loop: help-debbugs@gnu.org Subject: bug#27881: New major mode: Less mode Resent-From: Steve Purcell Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 31 Jul 2017 06:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27881 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier Cc: 27881@debbugs.gnu.org, tom@tromey.com, simenheg@gmail.com, dgutov@yandex.ru X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org, Tom Tromey , Simen =?UTF-8?Q?Heggest=C3=B8yl?= , Dmitry Gutov Received: via spool by submit@debbugs.gnu.org id=B.150148320128723 (code B ref -1); Mon, 31 Jul 2017 06:40:02 +0000 Received: (at submit) by debbugs.gnu.org; 31 Jul 2017 06:40:01 +0000 Received: from localhost ([127.0.0.1]:34724 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dc4Mz-0007TC-5q for submit@debbugs.gnu.org; Mon, 31 Jul 2017 02:40:01 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60618) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dc4Mx-0007Sz-9Q for submit@debbugs.gnu.org; Mon, 31 Jul 2017 02:39:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dc4Mq-0005j9-R1 for submit@debbugs.gnu.org; Mon, 31 Jul 2017 02:39:53 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:35220) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dc4Mq-0005j5-O6 for submit@debbugs.gnu.org; Mon, 31 Jul 2017 02:39:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51587) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dc4Mp-0003VI-IY for bug-gnu-emacs@gnu.org; Mon, 31 Jul 2017 02:39:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dc4Mk-0005iB-MR for bug-gnu-emacs@gnu.org; Mon, 31 Jul 2017 02:39:51 -0400 Received: from purcellpeople.com ([85.214.32.38]:41682 helo=h1189701.stratoserver.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dc4Mk-0005gW-Gy for bug-gnu-emacs@gnu.org; Mon, 31 Jul 2017 02:39:46 -0400 Received: from [192.168.0.4] (210-55-83-202.dialup.xtra.co.nz [210.55.83.202]) by h1189701.stratoserver.net (Postfix) with ESMTPSA id 196BA27AC0AD; Mon, 31 Jul 2017 08:39:29 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) From: Steve Purcell In-Reply-To: Date: Mon, 31 Jul 2017 18:39:23 +1200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <1501437183.13205.0@smtp.gmail.com> X-Mailer: Apple Mail (2.3273) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Comments below: >> ;;;###autoload >> -(defcustom less-css-lessc-command "lessc" >=20 > Why autoload all these defcustom. Sounds like a bug. It may well be superfluous, but I found a note that this was added = because non-autoloaded custom vars wouldn=E2=80=99t be considered safe = as dir local variables otherwise. > Since these defcusotm come right after the (defgroup less ..), the >=20 > :group 'less >=20 > is redundant. Agree. >> ;;;###autoload >> +(defun less-compile () >=20 > Why autoload? This operates on the current buffer, so presumably this > buffer is already in less-mode. Probably, yes. >> + (message "Compiling Less to CSS") >=20 > I notice that "Less" is used pretty much everywhere except in the > define-derived-mode where Steve used "LESS". Why not use "Less" in = the > mode name as well? Agree, consistency would be good. Official upstream name is =E2=80=9CLess=E2= =80=9D. >> + (append (list (less--maybe-shell-quote-command = less-lessc-command)) >=20 > I'd recommend to just never quote less-lessc-command rather than only > quote it on non-Windows systems. It's actually more flexible this way > since less-lessc-command can then be set to something fancier (e.g. = the > command with a few flags). This fixed a concrete bug, but yes, it=E2=80=99s probably misguided: it = would have been better to always leave it unquoted. However, I wouldn=E2=80=99t advocate adding arbitrary flags to a command = like this, because it can=E2=80=99t then be passed to one of the = =E2=80=9Cprocess=E2=80=9D functions that expects the first of its args = to be the path of the executable, right? >> +(defconst less-font-lock-keywords >> '(;; Variables >> - ("@[a-z_-][a-z-_0-9]*" . font-lock-constant-face) >> + ("@[a-z_-][a-z-_0-9]*" . font-lock-variable-name-face) >> ("&" . font-lock-preprocessor-face) >> ;; Mixins >> - ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" . (1 = font-lock-keyword-face))) >> - ) >> + ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" . >> + (1 font-lock-keyword-face)))) >=20 > Is it important to limit those to ASCII chars? If not, then it's = better > to use [[:alpha:]_-] and [[:alnum:]_-] in the above regexps. Unsure, but it=E2=80=99s likely safe to allow non-ASCII alphanumeric = chars.=20 >> +(define-key less-mode-map "\C-c\C-c" 'less-compile) >=20 > The standard way is to do: >=20 > (defvar less-mode-map > (let ((map (make-sparse-keymap)))) > (define-key map "\C-c\C-c" 'less-compile) > map) >=20 > before the `define-derived-mode=E2=80=99. Is there an advantage to this? My reasoning is that = =E2=80=9Cdefine-derived-mode=E2=80=9D generates the mode map = declaration, so why not fill it afterwards. If consistency is important, = though, this would be a reasonable thing to change. Thanks for the review! From unknown Sun Jun 22 20:58:12 2025 X-Loop: help-debbugs@gnu.org Subject: bug#27881: New major mode: Less mode Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 31 Jul 2017 12:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27881 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Steve Purcell Cc: 27881@debbugs.gnu.org, tom@tromey.com, simenheg@gmail.com, dgutov@yandex.ru X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org, Tom Tromey , Simen =?UTF-8?Q?Heggest=C3=B8yl?= , Dmitry Gutov Received: via spool by submit@debbugs.gnu.org id=B.15015050813423 (code B ref -1); Mon, 31 Jul 2017 12:45:02 +0000 Received: (at submit) by debbugs.gnu.org; 31 Jul 2017 12:44:41 +0000 Received: from localhost ([127.0.0.1]:34874 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dcA3t-0000t8-ED for submit@debbugs.gnu.org; Mon, 31 Jul 2017 08:44:41 -0400 Received: from eggs.gnu.org ([208.118.235.92]:42099) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dcA3r-0000sw-4m for submit@debbugs.gnu.org; Mon, 31 Jul 2017 08:44:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcA3k-0002fv-L6 for submit@debbugs.gnu.org; Mon, 31 Jul 2017 08:44:33 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:52361) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dcA3k-0002fr-Hr for submit@debbugs.gnu.org; Mon, 31 Jul 2017 08:44:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcA3j-00032w-GD for bug-gnu-emacs@gnu.org; Mon, 31 Jul 2017 08:44:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcA3e-0002c3-HF for bug-gnu-emacs@gnu.org; Mon, 31 Jul 2017 08:44:31 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:64861) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dcA3e-0002aj-9y for bug-gnu-emacs@gnu.org; Mon, 31 Jul 2017 08:44:26 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DCBABmJX9Z/+jlr2xdGwEBAQMBAQEJAQEBg1qQeI8EgWstAZdvhUEEAgKDfEQUAQIBAQEBAQEBayiFGQEEASMzIwULCxoCGA4CAhQYDSSKOgiteYImizoBAQgogQuCHYUugyeEdIMTgmEFkGuPBJ9JhxuULoFENiGBCjIhCDGHfiSKZQEBAQ X-IPAS-Result: A0DCBABmJX9Z/+jlr2xdGwEBAQMBAQEJAQEBg1qQeI8EgWstAZdvhUEEAgKDfEQUAQIBAQEBAQEBayiFGQEEASMzIwULCxoCGA4CAhQYDSSKOgiteYImizoBAQgogQuCHYUugyeEdIMTgmEFkGuPBJ9JhxuULoFENiGBCjIhCDGHfiSKZQEBAQ X-IronPort-AV: E=Sophos;i="5.40,442,1496116800"; d="scan'208";a="323346404" Received: from 108-175-229-232.dsl.teksavvy.com (HELO pastel.home) ([108.175.229.232]) by smtp.teksavvy.com with ESMTP; 31 Jul 2017 08:44:24 -0400 Received: by pastel.home (Postfix, from userid 20848) id 62A8D62B41; Mon, 31 Jul 2017 08:44:24 -0400 (EDT) From: Stefan Monnier Message-ID: References: <1501437183.13205.0@smtp.gmail.com> Date: Mon, 31 Jul 2017 08:44:24 -0400 In-Reply-To: (Steve Purcell's message of "Mon, 31 Jul 2017 18:39:23 +1200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) >>> ;;;###autoload >>> -(defcustom less-css-lessc-command "lessc" >> Why autoload all these defcustom. Sounds like a bug. > It may well be superfluous, but I found a note that this was added because > non-autoloaded custom vars wouldn=E2=80=99t be considered safe as dir loc= al > variables otherwise. The safety info may need to be autoloaded, indeed (IIUC we have a misfeature in there: we should enable the major mode (when possible) before checking safety of the local vars). But the vars themselves are better not autoloaded. > However, I wouldn=E2=80=99t advocate adding arbitrary flags to a command = like this, > because it can=E2=80=99t then be passed to one of the =E2=80=9Cprocess=E2= =80=9D functions that > expects the first of its args to be the path of the executable, right? Indeed, if you don't quote it there, it means it's a "shell" string and can hence only make sense when passed to a shell, rather than used directly as a file name. >> The standard way is to do: >> >> (defvar less-mode-map >> (let ((map (make-sparse-keymap)))) >> (define-key map "\C-c\C-c" 'less-compile) >> map) >> >> before the `define-derived-mode=E2=80=99. > Is there an advantage to this? Mostly consistency (each style has its quirks). Stefan From unknown Sun Jun 22 20:58:12 2025 X-Loop: help-debbugs@gnu.org Subject: bug#27881: New major mode: Less mode Resent-From: Tom Tromey Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 02 Aug 2017 02:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27881 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Cc: steve@sanityinc.com, 27881@debbugs.gnu.org, tom@tromey.com, monnier@iro.umontreal.ca, dgutov@yandex.ru X-Debbugs-Original-Cc: Steve Purcell , bug-gnu-emacs@gnu.org, Tom Tromey , Stefan Monnier , Dmitry Gutov Received: via spool by submit@debbugs.gnu.org id=B.150164026712650 (code B ref -1); Wed, 02 Aug 2017 02:18:02 +0000 Received: (at submit) by debbugs.gnu.org; 2 Aug 2017 02:17:47 +0000 Received: from localhost ([127.0.0.1]:37473 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dcjEI-0003Hy-JY for submit@debbugs.gnu.org; Tue, 01 Aug 2017 22:17:46 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40860) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dcjEF-0003Hk-Q8 for submit@debbugs.gnu.org; Tue, 01 Aug 2017 22:17:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcjE9-0003Qh-HF for submit@debbugs.gnu.org; Tue, 01 Aug 2017 22:17:38 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:60010) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dcjE9-0003Q6-E2 for submit@debbugs.gnu.org; Tue, 01 Aug 2017 22:17:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60031) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcjE8-0001l1-8g for bug-gnu-emacs@gnu.org; Tue, 01 Aug 2017 22:17:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcjDz-0003Ij-K6 for bug-gnu-emacs@gnu.org; Tue, 01 Aug 2017 22:17:33 -0400 Received: from gproxy9-pub.mail.unifiedlayer.com ([69.89.20.122]:40695) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dcjDz-00030s-9F for bug-gnu-emacs@gnu.org; Tue, 01 Aug 2017 22:17:27 -0400 Received: from cmgw4 (unknown [10.0.90.85]) by gproxy9.mail.unifiedlayer.com (Postfix) with ESMTP id AD4D01E0C34 for ; Tue, 1 Aug 2017 20:17:07 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id s2H31v00H2f2jeq012H6An; Tue, 01 Aug 2017 20:17:07 -0600 X-Authority-Analysis: v=2.2 cv=aJeAkf1m c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=IkcTkHD0fZMA:10 a=KeKAF7QvOSUA:10 a=pGLkceISAAAA:8 a=gQB6JClK7eoacdfokHIA:9 a=QEXdDO2ut3YA:10 a=6kGIvZw6iX1k4Y-7sg4_:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=L0XVDQTX5q1TIXhZogNvaZL/8dxojgG/9FhcAYi9PFI=; b=cwafiA9rvLSRR4UY5KAK1H4ufS QqdMRnxBK37E5jaE5O9FNAHaHjzkrInpX2sXsdwSziyr88iR6uynuysKe6vaOYfL1iaQXZ6/gmt6d xUnbJo4KWlI1ggiaSyhuY3zcw; Received: from 174-29-39-24.hlrn.qwest.net ([174.29.39.24]:51298 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dcjDa-000yCT-Vi; Tue, 01 Aug 2017 20:17:03 -0600 From: Tom Tromey References: <1501437183.13205.0@smtp.gmail.com> X-Attribution: Tom Date: Tue, 01 Aug 2017 20:16:59 -0600 In-Reply-To: <1501437183.13205.0@smtp.gmail.com> ("Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Sun, 30 Jul 2017 19:53:03 +0200") Message-ID: <87k22m90is.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box522.bluehost.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 174.29.39.24 X-Exim-ID: 1dcjDa-000yCT-Vi X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-29-39-24.hlrn.qwest.net (bapiya) [174.29.39.24]:51298 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) >>>>> "Simen" =3D=3D Simen Heggest=C3=B8yl writes: Simen> +(defcustom less-css-lessc-command "lessc" Simen> + "Command used to compile LESS files. Simen> +Should be lessc or the complete path to your lessc executable, Simen> + e.g.: \"~/.gem/ruby/1.8/bin/lessc\"" Simen> + :type 'file Simen> + :group 'less-css Simen> + :safe 'stringp) Simen> + Simen> +;;;###autoload Simen> +(defcustom less-css-compile-at-save nil Simen> + "If non-nil, the LESS buffers will be compiled to CSS after each = save." Simen> + :type 'boolean Simen> + :group 'less-css Simen> + :safe 'booleanp) It seems dangerous to me to mark these both as safe. A file could specify a dangerous command and then say it's ok to run it on save. Probably the command should not be :safe. Maybe the other variables defined after this should also not be safe. Tom From unknown Sun Jun 22 20:58:12 2025 X-Loop: help-debbugs@gnu.org Subject: bug#27881: New major mode: Less mode Resent-From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 03 Aug 2017 17:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27881 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Marcin Borkowski Cc: Glenn Morris , Stefan Monnier , Dmitry Gutov , Steve Purcell , Tom Tromey , 27881@debbugs.gnu.org Received: via spool by 27881-submit@debbugs.gnu.org id=B27881.150178248320053 (code B ref 27881); Thu, 03 Aug 2017 17:49:01 +0000 Received: (at 27881) by debbugs.gnu.org; 3 Aug 2017 17:48:03 +0000 Received: from localhost ([127.0.0.1]:40321 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddKE7-0005DM-0Q for submit@debbugs.gnu.org; Thu, 03 Aug 2017 13:48:03 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:35905) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddKE5-0005Ct-UH for 27881@debbugs.gnu.org; Thu, 03 Aug 2017 13:48:02 -0400 Received: by mail-lf0-f65.google.com with SMTP id t128so1409919lff.3 for <27881@debbugs.gnu.org>; Thu, 03 Aug 2017 10:48:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version; bh=afjtItzUpPFYS/Ei70JgjqPx13n8V1vghoy2xwbcd/M=; b=Q4wvWAqP/hiiGW0XtCDr8ov98hA//hhoGIAhrlBzOyO6I1lzxgg8SZLIObGBwXbuZd nuGxaOXzGVj0x5R+N3VV4WWMtXaecDFukeuNSMtGRCXTj2Ce/sG9hP3Bgoui3J3Qyh6L NUiLO6KWFSJSk3c0FwsMIs1GWXePIaCBSFF3SR2CBfGGTvkvKOPLW5B9sh5jPXJbpr7v 5Ogqq3V9B6pvrnH1ldHox1USOkfQ6p3CcIBivz9KjzW9Q4YqOkljHr7lrNvObpWwVmDZ LI6w82wB8lOaxWmYTZAPPHuvxvVxd/sPEL//R8T2KF4WTya1CRVg1IvQ5HLlFvUSRvZ4 g8FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to :references:mime-version; bh=afjtItzUpPFYS/Ei70JgjqPx13n8V1vghoy2xwbcd/M=; b=POoSCPAmoADXk+taP6dtN+09h0LLDDI+WoOESofRudPw1zuAVYwBRID4WAUmx0KAwH 2fl01H+zdSSJzIPqUbvpdXs1CW79UPMs1LdF7DLPBTvwkUx1N3Lm/k8BcuDHHqPi9k9X v7SbDARA3W0pz3p1cHdUtQKhf05tfHtsHwahScZIiF7FHFDNT+HUU/iFslF/EVbPRgc9 KS7muTY9sU45d3t8iWbw5qJ27DxlrwR1GyBiEVd7sZBcRoDjaFb88VOrsVRADsM5huRa poLKkENB3YwsGUHbfTLLVULcx9+KQtMAMNslHcelRH+layDX+xL59KDRuF/AScxWhE60 /M2w== X-Gm-Message-State: AHYfb5jMswYvvRJMfkBp04byZpbHhtKlFJcy/oQuTGGj3PetO9/EEGlr euu+vTVoqqtJQQ== X-Received: by 10.25.221.74 with SMTP id u71mr924635lfg.184.1501782475909; Thu, 03 Aug 2017 10:47:55 -0700 (PDT) Received: from [192.168.100.10] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id 17sm498284ljn.38.2017.08.03.10.47.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 03 Aug 2017 10:47:55 -0700 (PDT) Date: Thu, 03 Aug 2017 19:47:51 +0200 From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Message-Id: <1501782471.6810.0@smtp.gmail.com> In-Reply-To: <8760e92plk.fsf@jane> References: <1501437183.13205.0@smtp.gmail.com> <8760e92plk.fsf@jane> X-Mailer: geary/0.11.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) On Mon, Jul 31, 2017 at 6:32 AM, Marcin Borkowski wrote: > > On 2017-07-31, at 04:02, Glenn Morris wrote: >> FWIW, I would assume that "less-mode" was some sort of file viewer >> mode >> like the standalone less utility. > > Exactly my thought, I thought it is "view-mode on steroids"... > > -- > Marcin Borkowski Hmm, given these comments, I think it might be better to keep Steve's original name, "Less CSS mode". -- Simen From unknown Sun Jun 22 20:58:12 2025 X-Loop: help-debbugs@gnu.org Subject: bug#27881: New major mode: Less mode Resent-From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 03 Aug 2017 17:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27881 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Tom Tromey Cc: steve@sanityinc.com, 27881@debbugs.gnu.org, monnier@iro.umontreal.ca, dgutov@yandex.ru Received: via spool by 27881-submit@debbugs.gnu.org id=B27881.150178267820358 (code B ref 27881); Thu, 03 Aug 2017 17:52:01 +0000 Received: (at 27881) by debbugs.gnu.org; 3 Aug 2017 17:51:18 +0000 Received: from localhost ([127.0.0.1]:40325 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddKH8-0005I2-G6 for submit@debbugs.gnu.org; Thu, 03 Aug 2017 13:51:16 -0400 Received: from mail-lf0-f49.google.com ([209.85.215.49]:33764) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddKH5-0005He-ON for 27881@debbugs.gnu.org; Thu, 03 Aug 2017 13:51:09 -0400 Received: by mail-lf0-f49.google.com with SMTP id d17so9213225lfe.0 for <27881@debbugs.gnu.org>; Thu, 03 Aug 2017 10:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version; bh=m63GTWloDGmLv5YJdCKku8tjnQoko7Z4i+rDqv2gTa0=; b=L4jNtitbE4TjeJSnP2QIvjSoWVGJhkqT6hNb6oDiMShLB8zI4uEPUEmoS9ZiU0KEYq g4SrCU1Ilg43Ngne0pKIb2AX0Oqgk8+HF826w8OlPUWpVOF+VMQrRG7WFHtDHM7ei0d9 GzMYnCq64hOVU5ZR93LPKXtQTs+2+qnH+nGry0YcFEXBhPjddMsdYlTqmzdP5RiBg6VD j1sOkmVdK1ylf2Lvq9+BcdkmO56fI0NuxkwwUE4lvpTW3QpsGlVnO8tfsVTBoEdzlkfH M72bUMTwKixmi+5ee5xwX4nzI74DGRbDeZz36h0yjLpPy3Juoomm8yJV1QFNQ2rFEDGJ 7+lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to :references:mime-version; bh=m63GTWloDGmLv5YJdCKku8tjnQoko7Z4i+rDqv2gTa0=; b=jnEXn1qUkD/8B/IAW34ms97twDBQXliJTRcT8KfbsRfEaX2n24XRwTrSMM7j55basg cic2SxC5B25cnUTAkwXJfLBRJPgvsw10lhTkju4Ct+sAXlU9ZvRYu7eBhf8LmrqlTkBl 5fm995j82qD+RvSR/FZeHCGkPGuaf2LzZbU4ZpDMmnnP612qD7+uOn3uwh+F2NfkgPLJ orgfJhbH5TTfgd4cZeoHZQRAAQRODV9Ey68MOySOKfnL4Dgb4l5UZXp45hZaaR7Xv2cC lsTT7475WJ0IzlRkc6xGiCHNni0Y1J7jGWb951AMKeLgx4Si7norP1d4XHGHgiJ16CJo 20Kg== X-Gm-Message-State: AHYfb5jkV498eHaSpYtCZQmkV6C2fN1C595u6keDIidSg0+QxBAZ51vN grYHv3Mf6AAX+pwU X-Received: by 10.25.225.70 with SMTP id y67mr909669lfg.34.1501782662027; Thu, 03 Aug 2017 10:51:02 -0700 (PDT) Received: from [192.168.100.10] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id f88sm148286lji.47.2017.08.03.10.51.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 03 Aug 2017 10:51:00 -0700 (PDT) Date: Thu, 03 Aug 2017 19:50:58 +0200 From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Message-Id: <1501782658.6810.1@smtp.gmail.com> In-Reply-To: <87k22m90is.fsf@tromey.com> References: <1501437183.13205.0@smtp.gmail.com> <"Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Sun, 30 Jul 2017 19:53:03 +0200"> X-Mailer: geary/0.11.3 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-wU7UjnCtLc6993g+jM5r" X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) --=-wU7UjnCtLc6993g+jM5r Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable On Sun, Jul 30, 2017 at 10:59 PM, Stefan Monnier=20 wrote: > See some comments below. One thing, tho: an alternative would be to=20 put > it into its own file, which would give it more visibility Fine by me. Should we perhaps do the same for SCSS mode? On Mon, Jul 31, 2017 at 8:39 AM, Steve Purcell =20 wrote: > +(defconst less-font-lock-keywords > '(;; Variables > - ("@[a-z_-][a-z-_0-9]*" . font-lock-constant-face) > + ("@[a-z_-][a-z-_0-9]*" . font-lock-variable-name-face) > ("&" . font-lock-preprocessor-face) > ;; Mixins > - ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" . (1=20 font-lock-keyword-face))) > - ) > + ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" . > + (1 font-lock-keyword-face)))) > > Is it important to limit those to ASCII chars? If not, then it's=20 better > to use [[:alpha:]_-] and [[:alnum:]_-] in the above regexps. > > > Unsure, but it=E2=80=99s likely safe to allow non-ASCII alphanumeric cha= rs. I'm not sure either, but the Less compiler didn't like some non-ASCII characters I fed to it, so I suspect it only allows ASCII characters in variable names. On Mon, Jul 31, 2017 at 2:44 PM, Stefan Monnier=20 wrote: > The safety info may need to be autoloaded, indeed (IIUC we have > a misfeature in there: we should enable the major mode (when=20 possible) > before checking safety of the local vars). I've removed the autoloads from the defcustoms. How does one autoload safety info? On Wed, Aug 2, 2017 at 4:16 AM, Tom Tromey wrote: > It seems dangerous to me to mark these both as safe. A file could > specify a dangerous command and then say it's ok to run it on save. > > Probably the command should not be :safe. > > Maybe the other variables defined after this should also not be safe. > > Tom I think you're right, that seems particularly unsafe to me too. Maybe `less-css-output-file-name' shouldn't be marked safe either, since it may specify the name of an important file can get overwritten without a confirmation. I've updated the diffs based on your feedback. Thank you all for your comments so far. -- Simen = --=-wU7UjnCtLc6993g+jM5r Content-Type: multipart/mixed; boundary="=-ywzuS9897uoUaF6vLJRR" --=-ywzuS9897uoUaF6vLJRR Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-WIP-New-major-mode-Less-CSS-mode.patch Content-Transfer-Encoding: quoted-printable >From 5f7cbac4d28cfc245c81b1527d8995d3310d5388 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Simen=3D20Heggest=3DC3=3DB8yl?=3D Date: Tue, 1 Aug 2017 20:15:45 +0200 Subject: [PATCH 1/2] WIP: New major mode: Less CSS mode --- lisp/textmodes/less-css-mode.el | 258 ++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 258 insertions(+) create mode 100644 lisp/textmodes/less-css-mode.el diff --git a/lisp/textmodes/less-css-mode.el b/lisp/textmodes/less-css-mode= .el new file mode 100644 index 0000000000..8a981d67b9 --- /dev/null +++ b/lisp/textmodes/less-css-mode.el @@ -0,0 +1,258 @@ +;;; less-css-mode.el --- Major mode for editing LESS CSS files (lesscss.or= g) +;; +;; Copyright (C) 2011-2014 Steve Purcell +;; +;; Author: Steve Purcell +;; URL: https://github.com/purcell/less-css-mode +;; Keywords: less css mode +;; Version: DEV +;; +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 2 of +;; the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be +;; useful, but WITHOUT ANY WARRANTY; without even the implied +;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +;; PURPOSE. See the GNU General Public License for more details. +;; +;;; Commentary: +;; +;; This mode provides syntax highlighting for LESS CSS files, plus +;; optional support for compilation of .less files to .css files at +;; the time they are saved: use `less-css-compile-at-save' to enable +;; this. +;; +;; Command line utility "lessc" is required if setting +;; `less-css-compile-at-save' to t. To install "lessc" using the +;; Node.js package manager, run "npm install less" +;; +;; Also make sure the "lessc" executable is in Emacs' PATH, example: +;; (setq exec-path (cons (expand-file-name "~/.gem/ruby/1.8/bin") exec-pat= h)) +;; or customize `less-css-lessc-command' to point to your "lessc" executab= le. +;; +;; We target lessc >=3D 1.4.0, and thus use the `--no-color' flag by +;; default. You may want to adjust `less-css-lessc-options' for +;; compatibility with older versions. +;; +;; `less-css-mode' is derived from `css-mode', and indentation of +;; nested blocks may not work correctly with versions of `css-mode' +;; other than that bundled with recent Emacs. +;; +;; You can specify per-file values for `less-css-compile-at-save', +;; `less-css-output-file-name' or `less-css-output-directory' using a +;; variables header at the top of your .less file, e.g.: +;; +;; // -*- less-css-compile-at-save: t; less-css-output-directory: "../css"= -*- +;; +;; Alternatively, you can use directory local variables to set the +;; default value of `less-css-output-directory' for your project. +;; +;; In the case of files which are included in other .less files, you +;; may want to trigger the compilation of a "master" .less file on +;; save: you can accomplish this with `less-css-input-file-name', +;; which is probably best set using directory local variables. +;; +;; If you don't need CSS output but would like to be warned of any +;; syntax errors in your .less source, consider using `flymake-less': +;; https://github.com/purcell/flymake-less +;; +;;; Credits +;; +;; The original code for this mode was, in large part, written using +;; Anton Johansson's scss-mode as a template -- thanks Anton! +;; https://github.com/antonj +;; +;;; Code: + +(require 'derived) +(require 'compile) + +;; There are at least three css-mode.el implementations, but we need +;; the right one in order to work as expected, not the versions by +;; Landstr=C3=B6m or Garshol + +(require 'css-mode) +(unless (or (boundp 'css-navigation-syntax-table) + (functionp 'css-smie-rules)) + (error "Wrong css-mode.el: please use the version by Stefan Monnier, bun= dled with Emacs >=3D 23")) + +(defgroup less-css nil + "Less-css mode" + :prefix "less-css-" + :group 'css) + +;;;###autoload +(defcustom less-css-lessc-command "lessc" + "Command used to compile LESS files. +Should be lessc or the complete path to your lessc executable, + e.g.: \"~/.gem/ruby/1.8/bin/lessc\"" + :type 'file + :group 'less-css + :safe 'stringp) + +;;;###autoload +(defcustom less-css-compile-at-save nil + "If non-nil, the LESS buffers will be compiled to CSS after each save." + :type 'boolean + :group 'less-css + :safe 'booleanp) + +;;;###autoload +(defcustom less-css-lessc-options '("--no-color") + "Command line options for less executable. + +Use \"-x\" to minify output." + :type '(repeat string) + :group 'less-css + :safe t) + +;;;###autoload +(defcustom less-css-output-directory nil + "Directory in which to save CSS, or nil to use the LESS file's directory= . + +This path is expanded relative to the directory of the LESS file +using `expand-file-name', so both relative and absolute paths +will work as expected." + :type 'directory + :group 'less-css + :safe 'stringp) + +;;;###autoload +(defcustom less-css-output-file-name nil + "File name in which to save CSS, or nil to use .css for .les= s. + +This can be also be set to a full path, or a relative path. If +the path is relative, it will be relative to the value of +`less-css-output-dir', if set, or the current directory by +default." + :type 'file + :group 'less-css + :safe 'stringp) +(make-variable-buffer-local 'less-css-output-file-name) + +;;;###autoload +(defcustom less-css-input-file-name nil + "File name which will be compiled to CSS. + +When the current buffer is saved `less-css-input-file-name' file +will be compiled to css instead of the current file. + +Set this in order to trigger compilation of a \"master\" .less +file which includes the current file. The best way to set this +variable in most cases is likely to be via directory local +variables. + +This can be also be set to a full path, or a relative path. If +the path is relative, it will be relative to the the current directory by +default." + :type 'file + :group 'less-css + :safe 'stringp) +(make-variable-buffer-local 'less-css-input-file-name) + +(defconst less-css-default-error-regex + "^\\(?:\e\\[31m\\)?\\([^\e\n]*\\|FileError:.*\n\\)\\(?:\e\\[39m\e\\[31m\= \)? in \\(?:\e\\[39m\\)?\\([^ \r\n\t\e]+\\)\\(?:\e\\[90m\\)?\\(?::\\| on li= ne \\)\\([0-9]+\\)\\(?::\\|, column \\)\\([0-9]+\\):?\\(?:\e\\[39m\\)?") + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;; +;; Compilation to CSS +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;; + +(add-to-list 'compilation-error-regexp-alist-alist + (list 'less-css less-css-default-error-regex 2 3 4 nil 1)) +(add-to-list 'compilation-error-regexp-alist 'less-css) + + +(defun less-css-compile-maybe () + "Run `less-css-compile' if `less-css-compile-at-save' is non-nil." + (if less-css-compile-at-save + (less-css-compile))) + +(defun less-css--output-path () + "Calculate the path for the compiled CSS file created by `less-css-compi= le'." + (expand-file-name (or less-css-output-file-name + (concat (file-name-nondirectory (file-name-sans-ex= tension buffer-file-name)) ".css")) + (or less-css-output-directory default-directory))) + +(defun less-css--maybe-shell-quote-command (command) + "Selectively shell-quote COMMAND appropriately for `system-type'." + (funcall (if (eq system-type 'windows-nt) + 'identity + 'shell-quote-argument) command)) + +;;;###autoload +(defun less-css-compile () + "Compiles the current buffer to css using `less-css-lessc-command'." + (interactive) + (message "Compiling less to css") + (let ((compilation-buffer-name-function (lambda (mode-name) "*less-css-c= ompilation*"))) + (save-window-excursion + (with-current-buffer + (compile + (mapconcat 'identity + (append (list (less-css--maybe-shell-quote-command l= ess-css-lessc-command)) + (mapcar 'shell-quote-argument less-css-lessc= -options) + (list (shell-quote-argument + (or less-css-input-file-name buffer-f= ile-name)) + (shell-quote-argument (less-css--outpu= t-path)))) + " ")) + (add-hook 'compilation-finish-functions + (lambda (buf msg) + (unless (string-match-p "^finished" msg) + (display-buffer buf))) + nil + t))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;; +;; Minor mode +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;; + +;; TODO: interpolation ("@{val}"), escaped values (~"..."), JS eval (~`...= `), custom faces +(defconst less-css-font-lock-keywords + '(;; Variables + ("@[a-z_-][a-z-_0-9]*" . font-lock-constant-face) + ("&" . font-lock-preprocessor-face) + ;; Mixins + ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" . (1 font-loc= k-keyword-face))) + ) + +;;;###autoload +(define-derived-mode less-css-mode css-mode "LESS" + "Major mode for editing LESS files, http://lesscss.org/ +Special commands: +\\{less-css-mode-map}" + (font-lock-add-keywords nil less-css-font-lock-keywords) + ;; cpp-style comments + (modify-syntax-entry ?/ ". 124b" less-css-mode-syntax-table) + (modify-syntax-entry ?* ". 23" less-css-mode-syntax-table) + (modify-syntax-entry ?\n "> b" less-css-mode-syntax-table) + ;; Special chars that sometimes come at the beginning of words. + (modify-syntax-entry ?. "'" less-css-mode-syntax-table) + + (set (make-local-variable 'comment-start) "//") + (set (make-local-variable 'comment-end) "") + (set (make-local-variable 'indent-line-function) 'less-css-indent-line) + (when (functionp 'css-smie-rules) + (smie-setup css-smie-grammar #'css-smie-rules + :forward-token #'css-smie--forward-token + :backward-token #'css-smie--backward-token)) + + (add-hook 'after-save-hook 'less-css-compile-maybe nil t)) + +(define-key less-css-mode-map "\C-c\C-c" 'less-css-compile) + +(defun less-css-indent-line () + "Indent current line according to LESS CSS indentation rules." + (let ((css-navigation-syntax-table less-css-mode-syntax-table)) + (if (fboundp 'css-indent-line) + (css-indent-line) + (smie-indent-line)))) + +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.less\\'" . less-css-mode)) + + +(provide 'less-css-mode) +;;; less-css-mode.el ends here --=20 2.13.2 = --=-ywzuS9897uoUaF6vLJRR Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-WIP-Fixes-and-tweaks-for-the-new-Less-CSS-mode.patch Content-Transfer-Encoding: quoted-printable >From 030b430452b7a29f1231796c0f1bb65982eaf458 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Simen=3D20Heggest=3DC3=3DB8yl?=3D Date: Tue, 1 Aug 2017 20:23:21 +0200 Subject: [PATCH 2/2] WIP: Fixes and tweaks for the new Less CSS mode --- lisp/textmodes/less-css-mode.el | 239 +++++++++++++++++-------------------= ---- 1 file changed, 103 insertions(+), 136 deletions(-) diff --git a/lisp/textmodes/less-css-mode.el b/lisp/textmodes/less-css-mode= .el index 8a981d67b9..e54ae04364 100644 --- a/lisp/textmodes/less-css-mode.el +++ b/lisp/textmodes/less-css-mode.el @@ -1,36 +1,41 @@ -;;; less-css-mode.el --- Major mode for editing LESS CSS files (lesscss.or= g) -;; -;; Copyright (C) 2011-2014 Steve Purcell -;; +;;; less-css-mode.el --- Major mode for editing Less CSS files -*- lexica= l-binding: t; -*- + +;; Copyright (C) 2011-2017 Free Software Foundation, Inc. + ;; Author: Steve Purcell -;; URL: https://github.com/purcell/less-css-mode -;; Keywords: less css mode -;; Version: DEV -;; -;; This program is free software; you can redistribute it and/or -;; modify it under the terms of the GNU General Public License as -;; published by the Free Software Foundation; either version 2 of -;; the License, or (at your option) any later version. -;; -;; This program is distributed in the hope that it will be -;; useful, but WITHOUT ANY WARRANTY; without even the implied -;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -;; PURPOSE. See the GNU General Public License for more details. -;; +;; Maintainer: Simen Heggest=C3=B8yl +;; Keywords: hypermedia + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + ;;; Commentary: -;; -;; This mode provides syntax highlighting for LESS CSS files, plus -;; optional support for compilation of .less files to .css files at -;; the time they are saved: use `less-css-compile-at-save' to enable -;; this. + +;; This mode provides syntax highlighting for Less CSS files +;; (http://lesscss.org/), plus optional support for compilation of +;; .less files to .css files at the time they are saved: use +;; `less-css-compile-at-save' to enable this. ;; ;; Command line utility "lessc" is required if setting ;; `less-css-compile-at-save' to t. To install "lessc" using the -;; Node.js package manager, run "npm install less" +;; Node.js package manager, run "npm install less". ;; ;; Also make sure the "lessc" executable is in Emacs' PATH, example: -;; (setq exec-path (cons (expand-file-name "~/.gem/ruby/1.8/bin") exec-pat= h)) -;; or customize `less-css-lessc-command' to point to your "lessc" executab= le. +;; (push (expand-file-name "~/.gem/ruby/1.8/bin") exec-path) +;; or customize `less-css-lessc-command' to point to your "lessc" +;; executable. ;; ;; We target lessc >=3D 1.4.0, and thus use the `--no-color' flag by ;; default. You may want to adjust `less-css-lessc-options' for @@ -56,88 +61,64 @@ ;; ;; If you don't need CSS output but would like to be warned of any ;; syntax errors in your .less source, consider using `flymake-less': -;; https://github.com/purcell/flymake-less -;; +;; https://github.com/purcell/flymake-less. + ;;; Credits -;; + ;; The original code for this mode was, in large part, written using ;; Anton Johansson's scss-mode as a template -- thanks Anton! ;; https://github.com/antonj -;; + ;;; Code: =20 -(require 'derived) (require 'compile) - -;; There are at least three css-mode.el implementations, but we need -;; the right one in order to work as expected, not the versions by -;; Landstr=C3=B6m or Garshol - (require 'css-mode) -(unless (or (boundp 'css-navigation-syntax-table) - (functionp 'css-smie-rules)) - (error "Wrong css-mode.el: please use the version by Stefan Monnier, bun= dled with Emacs >=3D 23")) +(require 'derived) +(eval-when-compile (require 'subr-x)) =20 (defgroup less-css nil - "Less-css mode" + "Less CSS mode." :prefix "less-css-" :group 'css) =20 -;;;###autoload (defcustom less-css-lessc-command "lessc" - "Command used to compile LESS files. -Should be lessc or the complete path to your lessc executable, - e.g.: \"~/.gem/ruby/1.8/bin/lessc\"" - :type 'file - :group 'less-css - :safe 'stringp) + "Command used to compile Less files. +Should be \"lessc\" or the complete path to your lessc +executable, e.g.: \"~/.gem/ruby/1.8/bin/lessc\"." + :type 'file) =20 -;;;###autoload (defcustom less-css-compile-at-save nil - "If non-nil, the LESS buffers will be compiled to CSS after each save." + "If non-nil, Less buffers are compiled to CSS after each save." :type 'boolean - :group 'less-css :safe 'booleanp) =20 -;;;###autoload (defcustom less-css-lessc-options '("--no-color") - "Command line options for less executable. - + "Command line options for Less executable. Use \"-x\" to minify output." :type '(repeat string) - :group 'less-css :safe t) =20 -;;;###autoload (defcustom less-css-output-directory nil - "Directory in which to save CSS, or nil to use the LESS file's directory= . - -This path is expanded relative to the directory of the LESS file + "Directory in which to save CSS, or nil to use the Less file's directory= . +This path is expanded relative to the directory of the Less file using `expand-file-name', so both relative and absolute paths will work as expected." :type 'directory - :group 'less-css :safe 'stringp) =20 -;;;###autoload (defcustom less-css-output-file-name nil "File name in which to save CSS, or nil to use .css for .les= s. - This can be also be set to a full path, or a relative path. If the path is relative, it will be relative to the value of `less-css-output-dir', if set, or the current directory by default." - :type 'file - :group 'less-css - :safe 'stringp) + :type 'file) (make-variable-buffer-local 'less-css-output-file-name) =20 -;;;###autoload (defcustom less-css-input-file-name nil "File name which will be compiled to CSS. - When the current buffer is saved `less-css-input-file-name' file -will be compiled to css instead of the current file. +will be compiled to CSS instead of the current file. =20 Set this in order to trigger compilation of a \"master\" .less file which includes the current file. The best way to set this @@ -145,59 +126,53 @@ less-css-input-file-name variables. =20 This can be also be set to a full path, or a relative path. If -the path is relative, it will be relative to the the current directory by -default." +the path is relative, it will be relative to the the current +directory by default." :type 'file - :group 'less-css :safe 'stringp) (make-variable-buffer-local 'less-css-input-file-name) =20 (defconst less-css-default-error-regex "^\\(?:\e\\[31m\\)?\\([^\e\n]*\\|FileError:.*\n\\)\\(?:\e\\[39m\e\\[31m\= \)? in \\(?:\e\\[39m\\)?\\([^ \r\n\t\e]+\\)\\(?:\e\\[90m\\)?\\(?::\\| on li= ne \\)\\([0-9]+\\)\\(?::\\|, column \\)\\([0-9]+\\):?\\(?:\e\\[39m\\)?") =20 - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;; -;; Compilation to CSS -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;; +;;; Compilation to CSS =20 (add-to-list 'compilation-error-regexp-alist-alist (list 'less-css less-css-default-error-regex 2 3 4 nil 1)) (add-to-list 'compilation-error-regexp-alist 'less-css) =20 - (defun less-css-compile-maybe () "Run `less-css-compile' if `less-css-compile-at-save' is non-nil." - (if less-css-compile-at-save - (less-css-compile))) + (when less-css-compile-at-save + (less-css-compile))) =20 (defun less-css--output-path () - "Calculate the path for the compiled CSS file created by `less-css-compi= le'." - (expand-file-name (or less-css-output-file-name - (concat (file-name-nondirectory (file-name-sans-ex= tension buffer-file-name)) ".css")) - (or less-css-output-directory default-directory))) + "Return the path to use for the compiled CSS file." + (expand-file-name + (or less-css-output-file-name + (concat + (file-name-nondirectory + (file-name-sans-extension buffer-file-name)) + ".css")) + (or less-css-output-directory default-directory))) =20 -(defun less-css--maybe-shell-quote-command (command) - "Selectively shell-quote COMMAND appropriately for `system-type'." - (funcall (if (eq system-type 'windows-nt) - 'identity - 'shell-quote-argument) command)) - -;;;###autoload (defun less-css-compile () - "Compiles the current buffer to css using `less-css-lessc-command'." + "Compile the current buffer to CSS using `less-css-lessc-command'." (interactive) - (message "Compiling less to css") - (let ((compilation-buffer-name-function (lambda (mode-name) "*less-css-c= ompilation*"))) + (message "Compiling Less to CSS") + (let ((compilation-buffer-name-function + (lambda (_) "*less-css-compilation*"))) (save-window-excursion (with-current-buffer (compile - (mapconcat 'identity - (append (list (less-css--maybe-shell-quote-command l= ess-css-lessc-command)) - (mapcar 'shell-quote-argument less-css-lessc= -options) - (list (shell-quote-argument - (or less-css-input-file-name buffer-f= ile-name)) - (shell-quote-argument (less-css--outpu= t-path)))) - " ")) + (string-join + (append + (list less-css-lessc-command) + (mapcar #'shell-quote-argument less-css-lessc-options) + (list (shell-quote-argument + (or less-css-input-file-name buffer-file-name)) + (shell-quote-argument (less-css--output-path)))) + " ")) (add-hook 'compilation-finish-functions (lambda (buf msg) (unless (string-match-p "^finished" msg) @@ -205,54 +180,46 @@ less-css-compile nil t))))) =20 -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;; -;; Minor mode -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;; +;;; Major mode =20 -;; TODO: interpolation ("@{val}"), escaped values (~"..."), JS eval (~`...= `), custom faces +;; TODO: +;; - interpolation ("@{val}") +;; - escaped values (~"...") +;; - JS eval (~`...`) +;; - custom faces. (defconst less-css-font-lock-keywords '(;; Variables - ("@[a-z_-][a-z-_0-9]*" . font-lock-constant-face) + ("@[a-z_-][a-z-_0-9]*" . font-lock-variable-name-face) ("&" . font-lock-preprocessor-face) ;; Mixins - ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" . (1 font-loc= k-keyword-face))) - ) - + ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" . + (1 font-lock-keyword-face)))) + +(defvar less-css-mode-syntax-table + (let ((st (make-syntax-table css-mode-syntax-table))) + ;; C++-style comments. + (modify-syntax-entry ?/ ". 124b" st) + (modify-syntax-entry ?* ". 23" st) + (modify-syntax-entry ?\n "> b" st) + ;; Special chars that sometimes come at the beginning of words. + (modify-syntax-entry ?. "'" st) + st)) + +(defvar less-css-mode-map + (let ((map (make-sparse-keymap))) + (define-key map "\C-c\C-c" 'less-css-compile) + map)) + +;;;###autoload (add-to-list 'auto-mode-alist '("\\.less\\'" . less-css-mod= e)) ;;;###autoload -(define-derived-mode less-css-mode css-mode "LESS" - "Major mode for editing LESS files, http://lesscss.org/ +(define-derived-mode less-css-mode css-mode "Less" + "Major mode for editing Less files, http://lesscss.org/ Special commands: \\{less-css-mode-map}" (font-lock-add-keywords nil less-css-font-lock-keywords) - ;; cpp-style comments - (modify-syntax-entry ?/ ". 124b" less-css-mode-syntax-table) - (modify-syntax-entry ?* ". 23" less-css-mode-syntax-table) - (modify-syntax-entry ?\n "> b" less-css-mode-syntax-table) - ;; Special chars that sometimes come at the beginning of words. - (modify-syntax-entry ?. "'" less-css-mode-syntax-table) - - (set (make-local-variable 'comment-start) "//") - (set (make-local-variable 'comment-end) "") - (set (make-local-variable 'indent-line-function) 'less-css-indent-line) - (when (functionp 'css-smie-rules) - (smie-setup css-smie-grammar #'css-smie-rules - :forward-token #'css-smie--forward-token - :backward-token #'css-smie--backward-token)) - + (setq-local comment-start "//") + (setq-local comment-end "") (add-hook 'after-save-hook 'less-css-compile-maybe nil t)) =20 -(define-key less-css-mode-map "\C-c\C-c" 'less-css-compile) - -(defun less-css-indent-line () - "Indent current line according to LESS CSS indentation rules." - (let ((css-navigation-syntax-table less-css-mode-syntax-table)) - (if (fboundp 'css-indent-line) - (css-indent-line) - (smie-indent-line)))) - -;;;###autoload -(add-to-list 'auto-mode-alist '("\\.less\\'" . less-css-mode)) - - (provide 'less-css-mode) ;;; less-css-mode.el ends here --=20 2.13.2 = --=-ywzuS9897uoUaF6vLJRR-- --=-wU7UjnCtLc6993g+jM5r-- From unknown Sun Jun 22 20:58:12 2025 X-Loop: help-debbugs@gnu.org Subject: bug#27881: New major mode: Less mode Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 03 Aug 2017 20:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27881 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Cc: steve@sanityinc.com, Tom Tromey , 27881@debbugs.gnu.org, dgutov@yandex.ru Received: via spool by 27881-submit@debbugs.gnu.org id=B27881.150179094232543 (code B ref 27881); Thu, 03 Aug 2017 20:10:02 +0000 Received: (at 27881) by debbugs.gnu.org; 3 Aug 2017 20:09:02 +0000 Received: from localhost ([127.0.0.1]:40397 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddMQY-0008Sp-Lg for submit@debbugs.gnu.org; Thu, 03 Aug 2017 16:09:02 -0400 Received: from chene.dit.umontreal.ca ([132.204.246.20]:37490) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddMQW-0008SP-3Z for 27881@debbugs.gnu.org; Thu, 03 Aug 2017 16:09:01 -0400 Received: from lechazo.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id v73K8w6P019408; Thu, 3 Aug 2017 16:08:58 -0400 Received: by lechazo.home (Postfix, from userid 20848) id 9E6F8601CB; Thu, 3 Aug 2017 16:08:58 -0400 (EDT) From: Stefan Monnier Message-ID: References: <1501437183.13205.0@smtp.gmail.com> <1501782658.6810.1@smtp.gmail.com> Date: Thu, 03 Aug 2017 16:08:58 -0400 In-Reply-To: <1501782658.6810.1@smtp.gmail.com> ("Simen =?UTF-8?Q?Heggest=C3=B8yl?="'s message of "Thu, 03 Aug 2017 19:50:58 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6086=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6086> : inlines <6006> : streams <1757030> : uri <2475735> X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) >> See some comments below. One thing, tho: an alternative would be to >> put it into its own file, which would give it more visibility > Fine by me. Should we perhaps do the same for SCSS mode? We could, but since scss-mode was already included in Emacs-25.1 (i.e. it's been distributed officially for a while now), it's not as important. Putting it in its own file makes it possible to distribute it via GNU ELPA without having to wait for Emacs-26 to be released. > I've removed the autoloads from the defcustoms. How does one autoload > safety info? ;;;###autoload (put ' 'safe-local-variable ') -- Stefan From unknown Sun Jun 22 20:58:12 2025 X-Loop: help-debbugs@gnu.org Subject: bug#27881: New major mode: Less mode Resent-From: Richard Stallman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 04 Aug 2017 21:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27881 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Cc: mbork@mbork.pl, monnier@iro.umontreal.ca, dgutov@yandex.ru, steve@sanityinc.com, tom@tromey.com, 27881@debbugs.gnu.org Reply-To: rms@gnu.org Received: via spool by 27881-submit@debbugs.gnu.org id=B27881.150188245120071 (code B ref 27881); Fri, 04 Aug 2017 21:35:02 +0000 Received: (at 27881) by debbugs.gnu.org; 4 Aug 2017 21:34:11 +0000 Received: from localhost ([127.0.0.1]:42081 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddkEV-0005De-4B for submit@debbugs.gnu.org; Fri, 04 Aug 2017 17:34:11 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40528) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddkET-0005DR-AY for 27881@debbugs.gnu.org; Fri, 04 Aug 2017 17:34:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddkEN-0007uf-BE for 27881@debbugs.gnu.org; Fri, 04 Aug 2017 17:34:03 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:49890) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddkDW-0007G0-UM; Fri, 04 Aug 2017 17:33:10 -0400 Received: from rms by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1ddkDW-0002iz-Bo; Fri, 04 Aug 2017 17:33:10 -0400 From: Richard Stallman In-reply-to: <1501782471.6810.0@smtp.gmail.com> (message from Simen =?UTF-8?Q?Heggest=C3=B8yl?= on Thu, 03 Aug 2017 19:47:51 +0200) References: <1501437183.13205.0@smtp.gmail.com> <8760e92plk.fsf@jane> <1501782471.6810.0@smtp.gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-Id: Date: Fri, 04 Aug 2017 17:33:10 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) [[[ To any NSA and FBI agents reading my email: please consider ]]] [[[ whether defending the US Constitution against all enemies, ]]] [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > Hmm, given these comments, I think it might be better to keep Steve's > original name, "Less CSS mode". I agree. -- Dr Richard Stallman President, Free Software Foundation (gnu.org, fsf.org) Internet Hall-of-Famer (internethalloffame.org) Skype: No way! See stallman.org/skype.html. From unknown Sun Jun 22 20:58:12 2025 X-Loop: help-debbugs@gnu.org Subject: bug#27881: New major mode: Less mode Resent-From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 10 Aug 2017 22:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27881 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier Cc: steve@sanityinc.com, Tom Tromey , 27881@debbugs.gnu.org, dgutov@yandex.ru Received: via spool by 27881-submit@debbugs.gnu.org id=B27881.150240561924505 (code B ref 27881); Thu, 10 Aug 2017 22:54:02 +0000 Received: (at 27881) by debbugs.gnu.org; 10 Aug 2017 22:53:39 +0000 Received: from localhost ([127.0.0.1]:54825 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfwKc-0006N3-Iy for submit@debbugs.gnu.org; Thu, 10 Aug 2017 18:53:39 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:34579) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfwKY-0006Mo-JJ for 27881@debbugs.gnu.org; Thu, 10 Aug 2017 18:53:31 -0400 Received: by mail-qt0-f194.google.com with SMTP id i19so2191109qte.1 for <27881@debbugs.gnu.org>; Thu, 10 Aug 2017 15:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version; bh=Lug/YQOAmlW+T4FIiSCJ1BisJICnDM1cA3xjEZUV7CQ=; b=CwZwGkJWaagH/y8hdNzVlRUTnQ/cOy/TqE8yFPR2R71ICqx0U9U0vcBGIhv4bS8gjS sUGbz3uT1zsGMM6qH1PyZuaolx261mc0pMzIlRZnHalhhxydEtEmvMYqzQhqiCgVL2XQ aWFXXSK56ekMCApM1N7/78VIdpVdddAJZoZog2opQgONjd66kd3zkhyYPFUzk4CX7Htv bJNCKHACCjlIw4iCNW+1ZSmDONfa+5z0qFYgL4t0e0VVMTwgBhEocjHqg2gtaNE3Fk3o qmJG7hnEK0zeP/mW824IKt18EcRtoy6UnIRvNtBzVtygBpSymcnxyhG0CAXemMcnY9YV hhlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to :references:mime-version; bh=Lug/YQOAmlW+T4FIiSCJ1BisJICnDM1cA3xjEZUV7CQ=; b=IIHNyyteVC11svqPAHXkdkR2g0Cx1uQ9eZGEqxCay7icqRLzl5Wm5Siom1o2pbsWRP fEBGUJN2fq/ykSyGq+B66zjN+vR/Excpn51Ce9s/E8RNLkiHFQo5yGIuRk+TFq1i2wk7 OFQyOrPd4YxtJk81ezeHhkDMWpkk4WXAGyBObmqYNCbujLDnt4WGBdDbY3lmWCk0J7+/ rZEZ2LRcyX+PRj4s6l68lXn1SQK2FGrIp3kaw47TqeyyBexxrHDVpCiKte92ppye9Hwu oMnF2iFbQdjlMA90Rb+Mo0q9NCuDGz0Pq3vkd3Z89UsWBG/ZJ0lbi9Q0o+86PU7CWFZe b7iQ== X-Gm-Message-State: AHYfb5h8VNR9R/tsxA0HuyGlWato8/rlVxWkiNw3ucnvICi8THLzZvbu o2YPF39MfzF23g== X-Received: by 10.237.36.195 with SMTP id u3mr19362182qtc.151.1502405604890; Thu, 10 Aug 2017 15:53:24 -0700 (PDT) Received: from [192.168.2.165] (216-164-224-125.c3-0.tlg-cbr3.atw-tlg.pa.cable.rcn.com. [216.164.224.125]) by smtp.gmail.com with ESMTPSA id k36sm4801589qtc.41.2017.08.10.15.53.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Aug 2017 15:53:23 -0700 (PDT) Date: Fri, 11 Aug 2017 00:53:22 +0200 From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Message-Id: <1502405602.1756.4@smtp.gmail.com> In-Reply-To: References: <1501437183.13205.0@smtp.gmail.com> <1501782658.6810.1@smtp.gmail.com> <1501782658.6810.1@smtp.gmail.com> <"Simen =?UTF-8?Q?Heggest=C3=B8=3D=3FUTF-8=3FQ=3Fyl?="'s_message_of_"Thu, _03_Aug_2017_19:50:58_+0200"> X-Mailer: geary/0.11.3 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-ganHNVWVIOy0wIe+ow0v" X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) --=-ganHNVWVIOy0wIe+ow0v Content-Type: text/plain; charset=utf-8; format=flowed On Thu, Aug 3, 2017 at 10:08 PM, Stefan Monnier wrote: > ;;;###autoload > (put ' 'safe-local-variable ') OK, thanks. How does it look now? -- Simen --=-ganHNVWVIOy0wIe+ow0v Content-Type: multipart/mixed; boundary="=-AlcmsjUGNvt/L11XRzLB" --=-AlcmsjUGNvt/L11XRzLB Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-New-major-mode-Less-CSS-mode.patch Content-Transfer-Encoding: quoted-printable >From 8d24b049ee1d051b975da6b1e8707f0db42a1ac7 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Tue, 1 Aug 2017 20:15:45 +0200 Subject: [PATCH 1/2] New major mode: Less CSS mode * lisp/textmodes/less-css-mode.el: New file. --- lisp/textmodes/less-css-mode.el | 258 ++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 258 insertions(+) create mode 100644 lisp/textmodes/less-css-mode.el diff --git a/lisp/textmodes/less-css-mode.el b/lisp/textmodes/less-css-mode= .el new file mode 100644 index 0000000000..8a981d67b9 --- /dev/null +++ b/lisp/textmodes/less-css-mode.el @@ -0,0 +1,258 @@ +;;; less-css-mode.el --- Major mode for editing LESS CSS files (lesscss.or= g) +;; +;; Copyright (C) 2011-2014 Steve Purcell +;; +;; Author: Steve Purcell +;; URL: https://github.com/purcell/less-css-mode +;; Keywords: less css mode +;; Version: DEV +;; +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 2 of +;; the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be +;; useful, but WITHOUT ANY WARRANTY; without even the implied +;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +;; PURPOSE. See the GNU General Public License for more details. +;; +;;; Commentary: +;; +;; This mode provides syntax highlighting for LESS CSS files, plus +;; optional support for compilation of .less files to .css files at +;; the time they are saved: use `less-css-compile-at-save' to enable +;; this. +;; +;; Command line utility "lessc" is required if setting +;; `less-css-compile-at-save' to t. To install "lessc" using the +;; Node.js package manager, run "npm install less" +;; +;; Also make sure the "lessc" executable is in Emacs' PATH, example: +;; (setq exec-path (cons (expand-file-name "~/.gem/ruby/1.8/bin") exec-pat= h)) +;; or customize `less-css-lessc-command' to point to your "lessc" executab= le. +;; +;; We target lessc >=3D 1.4.0, and thus use the `--no-color' flag by +;; default. You may want to adjust `less-css-lessc-options' for +;; compatibility with older versions. +;; +;; `less-css-mode' is derived from `css-mode', and indentation of +;; nested blocks may not work correctly with versions of `css-mode' +;; other than that bundled with recent Emacs. +;; +;; You can specify per-file values for `less-css-compile-at-save', +;; `less-css-output-file-name' or `less-css-output-directory' using a +;; variables header at the top of your .less file, e.g.: +;; +;; // -*- less-css-compile-at-save: t; less-css-output-directory: "../css"= -*- +;; +;; Alternatively, you can use directory local variables to set the +;; default value of `less-css-output-directory' for your project. +;; +;; In the case of files which are included in other .less files, you +;; may want to trigger the compilation of a "master" .less file on +;; save: you can accomplish this with `less-css-input-file-name', +;; which is probably best set using directory local variables. +;; +;; If you don't need CSS output but would like to be warned of any +;; syntax errors in your .less source, consider using `flymake-less': +;; https://github.com/purcell/flymake-less +;; +;;; Credits +;; +;; The original code for this mode was, in large part, written using +;; Anton Johansson's scss-mode as a template -- thanks Anton! +;; https://github.com/antonj +;; +;;; Code: + +(require 'derived) +(require 'compile) + +;; There are at least three css-mode.el implementations, but we need +;; the right one in order to work as expected, not the versions by +;; Landstr=C3=B6m or Garshol + +(require 'css-mode) +(unless (or (boundp 'css-navigation-syntax-table) + (functionp 'css-smie-rules)) + (error "Wrong css-mode.el: please use the version by Stefan Monnier, bun= dled with Emacs >=3D 23")) + +(defgroup less-css nil + "Less-css mode" + :prefix "less-css-" + :group 'css) + +;;;###autoload +(defcustom less-css-lessc-command "lessc" + "Command used to compile LESS files. +Should be lessc or the complete path to your lessc executable, + e.g.: \"~/.gem/ruby/1.8/bin/lessc\"" + :type 'file + :group 'less-css + :safe 'stringp) + +;;;###autoload +(defcustom less-css-compile-at-save nil + "If non-nil, the LESS buffers will be compiled to CSS after each save." + :type 'boolean + :group 'less-css + :safe 'booleanp) + +;;;###autoload +(defcustom less-css-lessc-options '("--no-color") + "Command line options for less executable. + +Use \"-x\" to minify output." + :type '(repeat string) + :group 'less-css + :safe t) + +;;;###autoload +(defcustom less-css-output-directory nil + "Directory in which to save CSS, or nil to use the LESS file's directory= . + +This path is expanded relative to the directory of the LESS file +using `expand-file-name', so both relative and absolute paths +will work as expected." + :type 'directory + :group 'less-css + :safe 'stringp) + +;;;###autoload +(defcustom less-css-output-file-name nil + "File name in which to save CSS, or nil to use .css for .les= s. + +This can be also be set to a full path, or a relative path. If +the path is relative, it will be relative to the value of +`less-css-output-dir', if set, or the current directory by +default." + :type 'file + :group 'less-css + :safe 'stringp) +(make-variable-buffer-local 'less-css-output-file-name) + +;;;###autoload +(defcustom less-css-input-file-name nil + "File name which will be compiled to CSS. + +When the current buffer is saved `less-css-input-file-name' file +will be compiled to css instead of the current file. + +Set this in order to trigger compilation of a \"master\" .less +file which includes the current file. The best way to set this +variable in most cases is likely to be via directory local +variables. + +This can be also be set to a full path, or a relative path. If +the path is relative, it will be relative to the the current directory by +default." + :type 'file + :group 'less-css + :safe 'stringp) +(make-variable-buffer-local 'less-css-input-file-name) + +(defconst less-css-default-error-regex + "^\\(?:\e\\[31m\\)?\\([^\e\n]*\\|FileError:.*\n\\)\\(?:\e\\[39m\e\\[31m\= \)? in \\(?:\e\\[39m\\)?\\([^ \r\n\t\e]+\\)\\(?:\e\\[90m\\)?\\(?::\\| on li= ne \\)\\([0-9]+\\)\\(?::\\|, column \\)\\([0-9]+\\):?\\(?:\e\\[39m\\)?") + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;; +;; Compilation to CSS +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;; + +(add-to-list 'compilation-error-regexp-alist-alist + (list 'less-css less-css-default-error-regex 2 3 4 nil 1)) +(add-to-list 'compilation-error-regexp-alist 'less-css) + + +(defun less-css-compile-maybe () + "Run `less-css-compile' if `less-css-compile-at-save' is non-nil." + (if less-css-compile-at-save + (less-css-compile))) + +(defun less-css--output-path () + "Calculate the path for the compiled CSS file created by `less-css-compi= le'." + (expand-file-name (or less-css-output-file-name + (concat (file-name-nondirectory (file-name-sans-ex= tension buffer-file-name)) ".css")) + (or less-css-output-directory default-directory))) + +(defun less-css--maybe-shell-quote-command (command) + "Selectively shell-quote COMMAND appropriately for `system-type'." + (funcall (if (eq system-type 'windows-nt) + 'identity + 'shell-quote-argument) command)) + +;;;###autoload +(defun less-css-compile () + "Compiles the current buffer to css using `less-css-lessc-command'." + (interactive) + (message "Compiling less to css") + (let ((compilation-buffer-name-function (lambda (mode-name) "*less-css-c= ompilation*"))) + (save-window-excursion + (with-current-buffer + (compile + (mapconcat 'identity + (append (list (less-css--maybe-shell-quote-command l= ess-css-lessc-command)) + (mapcar 'shell-quote-argument less-css-lessc= -options) + (list (shell-quote-argument + (or less-css-input-file-name buffer-f= ile-name)) + (shell-quote-argument (less-css--outpu= t-path)))) + " ")) + (add-hook 'compilation-finish-functions + (lambda (buf msg) + (unless (string-match-p "^finished" msg) + (display-buffer buf))) + nil + t))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;; +;; Minor mode +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;; + +;; TODO: interpolation ("@{val}"), escaped values (~"..."), JS eval (~`...= `), custom faces +(defconst less-css-font-lock-keywords + '(;; Variables + ("@[a-z_-][a-z-_0-9]*" . font-lock-constant-face) + ("&" . font-lock-preprocessor-face) + ;; Mixins + ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" . (1 font-loc= k-keyword-face))) + ) + +;;;###autoload +(define-derived-mode less-css-mode css-mode "LESS" + "Major mode for editing LESS files, http://lesscss.org/ +Special commands: +\\{less-css-mode-map}" + (font-lock-add-keywords nil less-css-font-lock-keywords) + ;; cpp-style comments + (modify-syntax-entry ?/ ". 124b" less-css-mode-syntax-table) + (modify-syntax-entry ?* ". 23" less-css-mode-syntax-table) + (modify-syntax-entry ?\n "> b" less-css-mode-syntax-table) + ;; Special chars that sometimes come at the beginning of words. + (modify-syntax-entry ?. "'" less-css-mode-syntax-table) + + (set (make-local-variable 'comment-start) "//") + (set (make-local-variable 'comment-end) "") + (set (make-local-variable 'indent-line-function) 'less-css-indent-line) + (when (functionp 'css-smie-rules) + (smie-setup css-smie-grammar #'css-smie-rules + :forward-token #'css-smie--forward-token + :backward-token #'css-smie--backward-token)) + + (add-hook 'after-save-hook 'less-css-compile-maybe nil t)) + +(define-key less-css-mode-map "\C-c\C-c" 'less-css-compile) + +(defun less-css-indent-line () + "Indent current line according to LESS CSS indentation rules." + (let ((css-navigation-syntax-table less-css-mode-syntax-table)) + (if (fboundp 'css-indent-line) + (css-indent-line) + (smie-indent-line)))) + +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.less\\'" . less-css-mode)) + + +(provide 'less-css-mode) +;;; less-css-mode.el ends here --=20 2.13.2 = --=-AlcmsjUGNvt/L11XRzLB Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-Fixes-and-tweaks-for-the-new-Less-CSS-mode.patch Content-Transfer-Encoding: quoted-printable >From cdf3582216b9f0a5a031dbad5784d87dbabb8a36 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Simen=3D20Heggest=3DC3=3DB8yl?=3D Date: Tue, 1 Aug 2017 20:23:21 +0200 Subject: [PATCH 2/2] Fixes and tweaks for the new Less CSS mode * etc/NEWS: Add an entry for the new mode. * lisp/textmodes/less-css-mode.el (less-css): Tweak docstring. (less-css-lessc-command): Tweak docstring. Don't mark it as safe. Don't autoload. (less-css-compile-at-save, less-css-lessc-options) (less-css-output-directory): Tweak docstrings. Don't autoload. (less-css-output-file-name): Tweak docstring. Don't mark it as safe. (less-css-input-file-name): Tweak docstring. Don't autoload. (less-css-compile-maybe): Use `when' for one-armed `if'. (less-css--output-path): Tweak docstring. (less-css--maybe-shell-quote-command): Remove function. (less-css-compile): Don't autoload. Tweak docstring and message. Fix compiler warning. Use `string-join' instead of `mapconcat'. (less-css-font-lock-keywords): Use `font-lock-variable-name-face' for variables. (less-css-mode-syntax-table, less-css-mode-map): New variables. (less-css-mode): Change status line mode name from "LESS" to "Less". Tweak docstring. Move syntax table definitions to `less-css-mode-syntax-table'. (less-css-indent-line): Remove function. --- etc/NEWS | 3 + lisp/textmodes/less-css-mode.el | 261 ++++++++++++++++++------------------= ---- 2 files changed, 119 insertions(+), 145 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 2b789be3c8..7c2172947e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1100,6 +1100,9 @@ fontification, and commenting for embedded JavaScript= and CSS. =20 ** New minor mode 'pixel-scroll-mode' provides smooth pixel-level scrollin= g. =20 +** New major mode 'less-css-mode' (a minor variant of 'css-mode') for +editing Less files. + =0C * Incompatible Lisp Changes in Emacs 26.1 =20 diff --git a/lisp/textmodes/less-css-mode.el b/lisp/textmodes/less-css-mode= .el index 8a981d67b9..1d3f2c6b8d 100644 --- a/lisp/textmodes/less-css-mode.el +++ b/lisp/textmodes/less-css-mode.el @@ -1,36 +1,41 @@ -;;; less-css-mode.el --- Major mode for editing LESS CSS files (lesscss.or= g) -;; -;; Copyright (C) 2011-2014 Steve Purcell -;; +;;; less-css-mode.el --- Major mode for editing Less CSS files -*- lexica= l-binding: t; -*- + +;; Copyright (C) 2011-2017 Free Software Foundation, Inc. + ;; Author: Steve Purcell -;; URL: https://github.com/purcell/less-css-mode -;; Keywords: less css mode -;; Version: DEV -;; -;; This program is free software; you can redistribute it and/or -;; modify it under the terms of the GNU General Public License as -;; published by the Free Software Foundation; either version 2 of -;; the License, or (at your option) any later version. -;; -;; This program is distributed in the hope that it will be -;; useful, but WITHOUT ANY WARRANTY; without even the implied -;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -;; PURPOSE. See the GNU General Public License for more details. -;; +;; Maintainer: Simen Heggest=C3=B8yl +;; Keywords: hypermedia + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + ;;; Commentary: -;; -;; This mode provides syntax highlighting for LESS CSS files, plus -;; optional support for compilation of .less files to .css files at -;; the time they are saved: use `less-css-compile-at-save' to enable -;; this. + +;; This mode provides syntax highlighting for Less CSS files +;; (http://lesscss.org/), plus optional support for compilation of +;; .less files to .css files at the time they are saved: use +;; `less-css-compile-at-save' to enable this. ;; ;; Command line utility "lessc" is required if setting ;; `less-css-compile-at-save' to t. To install "lessc" using the -;; Node.js package manager, run "npm install less" +;; Node.js package manager, run "npm install less". ;; ;; Also make sure the "lessc" executable is in Emacs' PATH, example: -;; (setq exec-path (cons (expand-file-name "~/.gem/ruby/1.8/bin") exec-pat= h)) -;; or customize `less-css-lessc-command' to point to your "lessc" executab= le. +;; (push (expand-file-name "~/.gem/ruby/1.8/bin") exec-path) +;; or customize `less-css-lessc-command' to point to your "lessc" +;; executable. ;; ;; We target lessc >=3D 1.4.0, and thus use the `--no-color' flag by ;; default. You may want to adjust `less-css-lessc-options' for @@ -56,148 +61,122 @@ ;; ;; If you don't need CSS output but would like to be warned of any ;; syntax errors in your .less source, consider using `flymake-less': -;; https://github.com/purcell/flymake-less -;; +;; https://github.com/purcell/flymake-less. + ;;; Credits -;; + ;; The original code for this mode was, in large part, written using ;; Anton Johansson's scss-mode as a template -- thanks Anton! ;; https://github.com/antonj -;; + ;;; Code: =20 -(require 'derived) (require 'compile) - -;; There are at least three css-mode.el implementations, but we need -;; the right one in order to work as expected, not the versions by -;; Landstr=C3=B6m or Garshol - (require 'css-mode) -(unless (or (boundp 'css-navigation-syntax-table) - (functionp 'css-smie-rules)) - (error "Wrong css-mode.el: please use the version by Stefan Monnier, bun= dled with Emacs >=3D 23")) +(require 'derived) +(eval-when-compile (require 'subr-x)) =20 (defgroup less-css nil - "Less-css mode" + "Less CSS mode." :prefix "less-css-" :group 'css) =20 -;;;###autoload (defcustom less-css-lessc-command "lessc" - "Command used to compile LESS files. -Should be lessc or the complete path to your lessc executable, - e.g.: \"~/.gem/ruby/1.8/bin/lessc\"" - :type 'file - :group 'less-css - :safe 'stringp) + "Command used to compile Less files. +Should be \"lessc\" or the complete path to your lessc +executable, e.g.: \"~/.gem/ruby/1.8/bin/lessc\"." + :type 'file) =20 -;;;###autoload (defcustom less-css-compile-at-save nil - "If non-nil, the LESS buffers will be compiled to CSS after each save." - :type 'boolean - :group 'less-css - :safe 'booleanp) - + "If non-nil, Less buffers are compiled to CSS after each save." + :type 'boolean) ;;;###autoload -(defcustom less-css-lessc-options '("--no-color") - "Command line options for less executable. +(put 'less-css-compile-at-save 'safe-local-variable 'booleanp) =20 +(defcustom less-css-lessc-options '("--no-color") + "Command line options for Less executable. Use \"-x\" to minify output." - :type '(repeat string) - :group 'less-css - :safe t) - + :type '(repeat string)) ;;;###autoload -(defcustom less-css-output-directory nil - "Directory in which to save CSS, or nil to use the LESS file's directory= . +(put 'less-css-lessc-options 'safe-local-variable t) =20 -This path is expanded relative to the directory of the LESS file +(defcustom less-css-output-directory nil + "Directory in which to save CSS, or nil to use the Less file's directory= . +This path is expanded relative to the directory of the Less file using `expand-file-name', so both relative and absolute paths will work as expected." - :type 'directory - :group 'less-css - :safe 'stringp) - + :type 'directory) ;;;###autoload +(put 'less-css-output-directory 'safe-local-variable 'stringp) + (defcustom less-css-output-file-name nil "File name in which to save CSS, or nil to use .css for .les= s. - This can be also be set to a full path, or a relative path. If the path is relative, it will be relative to the value of `less-css-output-dir', if set, or the current directory by default." - :type 'file - :group 'less-css - :safe 'stringp) + :type 'file) (make-variable-buffer-local 'less-css-output-file-name) =20 -;;;###autoload (defcustom less-css-input-file-name nil "File name which will be compiled to CSS. - When the current buffer is saved `less-css-input-file-name' file -will be compiled to css instead of the current file. +will be compiled to CSS instead of the current file. =20 Set this in order to trigger compilation of a \"master\" .less file which includes the current file. The best way to set this variable in most cases is likely to be via directory local variables. =20 -This can be also be set to a full path, or a relative path. If -the path is relative, it will be relative to the the current directory by -default." - :type 'file - :group 'less-css - :safe 'stringp) +This can be also be set to a full path, or a relative path. If +the path is relative, it will be relative to the the current +directory by default." + :type 'file) +;;;###autoload +(put 'less-css-input-file-name 'safe-local-variable 'stringp) (make-variable-buffer-local 'less-css-input-file-name) =20 (defconst less-css-default-error-regex "^\\(?:\e\\[31m\\)?\\([^\e\n]*\\|FileError:.*\n\\)\\(?:\e\\[39m\e\\[31m\= \)? in \\(?:\e\\[39m\\)?\\([^ \r\n\t\e]+\\)\\(?:\e\\[90m\\)?\\(?::\\| on li= ne \\)\\([0-9]+\\)\\(?::\\|, column \\)\\([0-9]+\\):?\\(?:\e\\[39m\\)?") =20 - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;; -;; Compilation to CSS -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;; +;;; Compilation to CSS =20 (add-to-list 'compilation-error-regexp-alist-alist (list 'less-css less-css-default-error-regex 2 3 4 nil 1)) (add-to-list 'compilation-error-regexp-alist 'less-css) =20 - (defun less-css-compile-maybe () "Run `less-css-compile' if `less-css-compile-at-save' is non-nil." - (if less-css-compile-at-save - (less-css-compile))) + (when less-css-compile-at-save + (less-css-compile))) =20 (defun less-css--output-path () - "Calculate the path for the compiled CSS file created by `less-css-compi= le'." - (expand-file-name (or less-css-output-file-name - (concat (file-name-nondirectory (file-name-sans-ex= tension buffer-file-name)) ".css")) - (or less-css-output-directory default-directory))) + "Return the path to use for the compiled CSS file." + (expand-file-name + (or less-css-output-file-name + (concat + (file-name-nondirectory + (file-name-sans-extension buffer-file-name)) + ".css")) + (or less-css-output-directory default-directory))) =20 -(defun less-css--maybe-shell-quote-command (command) - "Selectively shell-quote COMMAND appropriately for `system-type'." - (funcall (if (eq system-type 'windows-nt) - 'identity - 'shell-quote-argument) command)) - -;;;###autoload (defun less-css-compile () - "Compiles the current buffer to css using `less-css-lessc-command'." + "Compile the current buffer to CSS using `less-css-lessc-command'." (interactive) - (message "Compiling less to css") - (let ((compilation-buffer-name-function (lambda (mode-name) "*less-css-c= ompilation*"))) + (message "Compiling Less to CSS") + (let ((compilation-buffer-name-function + (lambda (_) "*less-css-compilation*"))) (save-window-excursion (with-current-buffer (compile - (mapconcat 'identity - (append (list (less-css--maybe-shell-quote-command l= ess-css-lessc-command)) - (mapcar 'shell-quote-argument less-css-lessc= -options) - (list (shell-quote-argument - (or less-css-input-file-name buffer-f= ile-name)) - (shell-quote-argument (less-css--outpu= t-path)))) - " ")) + (string-join + (append + (list less-css-lessc-command) + (mapcar #'shell-quote-argument less-css-lessc-options) + (list (shell-quote-argument + (or less-css-input-file-name buffer-file-name)) + (shell-quote-argument (less-css--output-path)))) + " ")) (add-hook 'compilation-finish-functions (lambda (buf msg) (unless (string-match-p "^finished" msg) @@ -205,54 +184,46 @@ less-css-compile nil t))))) =20 -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;; -;; Minor mode -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;; +;;; Major mode =20 -;; TODO: interpolation ("@{val}"), escaped values (~"..."), JS eval (~`...= `), custom faces +;; TODO: +;; - interpolation ("@{val}") +;; - escaped values (~"...") +;; - JS eval (~`...`) +;; - custom faces. (defconst less-css-font-lock-keywords '(;; Variables - ("@[a-z_-][a-z-_0-9]*" . font-lock-constant-face) + ("@[a-z_-][a-z-_0-9]*" . font-lock-variable-name-face) ("&" . font-lock-preprocessor-face) ;; Mixins - ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" . (1 font-loc= k-keyword-face))) - ) - + ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" . + (1 font-lock-keyword-face)))) + +(defvar less-css-mode-syntax-table + (let ((st (make-syntax-table css-mode-syntax-table))) + ;; C++-style comments. + (modify-syntax-entry ?/ ". 124b" st) + (modify-syntax-entry ?* ". 23" st) + (modify-syntax-entry ?\n "> b" st) + ;; Special chars that sometimes come at the beginning of words. + (modify-syntax-entry ?. "'" st) + st)) + +(defvar less-css-mode-map + (let ((map (make-sparse-keymap))) + (define-key map "\C-c\C-c" 'less-css-compile) + map)) + +;;;###autoload (add-to-list 'auto-mode-alist '("\\.less\\'" . less-css-mod= e)) ;;;###autoload -(define-derived-mode less-css-mode css-mode "LESS" - "Major mode for editing LESS files, http://lesscss.org/ +(define-derived-mode less-css-mode css-mode "Less" + "Major mode for editing Less files (http://lesscss.org/). Special commands: \\{less-css-mode-map}" (font-lock-add-keywords nil less-css-font-lock-keywords) - ;; cpp-style comments - (modify-syntax-entry ?/ ". 124b" less-css-mode-syntax-table) - (modify-syntax-entry ?* ". 23" less-css-mode-syntax-table) - (modify-syntax-entry ?\n "> b" less-css-mode-syntax-table) - ;; Special chars that sometimes come at the beginning of words. - (modify-syntax-entry ?. "'" less-css-mode-syntax-table) - - (set (make-local-variable 'comment-start) "//") - (set (make-local-variable 'comment-end) "") - (set (make-local-variable 'indent-line-function) 'less-css-indent-line) - (when (functionp 'css-smie-rules) - (smie-setup css-smie-grammar #'css-smie-rules - :forward-token #'css-smie--forward-token - :backward-token #'css-smie--backward-token)) - + (setq-local comment-start "//") + (setq-local comment-end "") (add-hook 'after-save-hook 'less-css-compile-maybe nil t)) =20 -(define-key less-css-mode-map "\C-c\C-c" 'less-css-compile) - -(defun less-css-indent-line () - "Indent current line according to LESS CSS indentation rules." - (let ((css-navigation-syntax-table less-css-mode-syntax-table)) - (if (fboundp 'css-indent-line) - (css-indent-line) - (smie-indent-line)))) - -;;;###autoload -(add-to-list 'auto-mode-alist '("\\.less\\'" . less-css-mode)) - - (provide 'less-css-mode) ;;; less-css-mode.el ends here --=20 2.13.2 = --=-AlcmsjUGNvt/L11XRzLB-- --=-ganHNVWVIOy0wIe+ow0v-- From unknown Sun Jun 22 20:58:12 2025 X-Loop: help-debbugs@gnu.org Subject: bug#27881: New major mode: Less mode Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 14 Aug 2017 10:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27881 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Cc: steve@sanityinc.com, Tom Tromey , 27881@debbugs.gnu.org, dgutov@yandex.ru Received: via spool by 27881-submit@debbugs.gnu.org id=B27881.15027052211588 (code B ref 27881); Mon, 14 Aug 2017 10:07:02 +0000 Received: (at 27881) by debbugs.gnu.org; 14 Aug 2017 10:07:01 +0000 Received: from localhost ([127.0.0.1]:35062 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhCGy-0000PY-Ri for submit@debbugs.gnu.org; Mon, 14 Aug 2017 06:07:01 -0400 Received: from chene.dit.umontreal.ca ([132.204.246.20]:53013) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhCGx-0000PS-64 for 27881@debbugs.gnu.org; Mon, 14 Aug 2017 06:06:59 -0400 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id v7EA6tnV004207; Mon, 14 Aug 2017 06:06:56 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 1739466334; Mon, 14 Aug 2017 06:06:55 -0400 (EDT) From: Stefan Monnier Message-ID: References: <1501437183.13205.0@smtp.gmail.com> <1501782658.6810.1@smtp.gmail.com> <=?UTF-8?Q?1501782658.6810.1@smtp.gmail.com> <1502405602.1756.4@smtp.gmail.com> Date: Mon, 14 Aug 2017 06:06:55 -0400 In-Reply-To: <1502405602.1756.4@smtp.gmail.com> ("Simen =?UTF-8?Q?Heggest=C3=B8yl?="'s message of "Fri, 11 Aug 2017 00:53:22 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Level: X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0.1 X-NAI-Spam-Rules: 3 Rules triggered GEN_SPAM_FEATRE=0.1, EDT_SA_DN_PASS=0, RV6092=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6092> : inlines <6018> : streams <1758535> : uri <2482845> X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) > How does it look now? Fine by me, Stefan From unknown Sun Jun 22 20:58:12 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Subject: bug#27881: closed (Re: bug#27881: New major mode: Less mode) Message-ID: References: <1502793233.29571.1@smtp.gmail.com> <1501437183.13205.0@smtp.gmail.com> X-Gnu-PR-Message: they-closed 27881 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 27881@debbugs.gnu.org Date: Tue, 15 Aug 2017 10:35:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1502793302-9022-1" This is a multi-part message in MIME format... ------------=_1502793302-9022-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #27881: New major mode: Less mode which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 27881@debbugs.gnu.org. --=20 27881: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D27881 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1502793302-9022-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 27881-done) by debbugs.gnu.org; 15 Aug 2017 10:34:05 +0000 Received: from localhost ([127.0.0.1]:37757 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhZAi-0002Kz-PR for submit@debbugs.gnu.org; Tue, 15 Aug 2017 06:34:04 -0400 Received: from mail-lf0-f45.google.com ([209.85.215.45]:36338) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhZAg-0002KY-Nc for 27881-done@debbugs.gnu.org; Tue, 15 Aug 2017 06:34:03 -0400 Received: by mail-lf0-f45.google.com with SMTP id o85so2164602lff.3 for <27881-done@debbugs.gnu.org>; Tue, 15 Aug 2017 03:34:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version; bh=cJ55pS2zCQ/J6yyrgfUByQHKsTBsW6N4W1N9+lzzch8=; b=HiroHK8BO7FfH//zQISQPFdei1Nj2KIiZHBMi0NN3I2sDlkiEqBrODqjcrUKfsAbam p4WWwlIYHEP9NVqhWhmUTMsbt0Rw2xiw3d+JnpfZCtveQc0ylpzqCiHrFQdHAF4SDLKL LyteazDqqyW3+5+bTJagRa+SKNGxwbdebJce/fhwPM79967QKrtaVEnj7WosRaxRiKJj aJW7iB1uN7X0OZZcmh/lYWRE0Nm73KzzpWMYKmXJztx5xPHmr/UEx8622a6yFi3EmONd lcwZPXYNEjlIgsHcWJttLGmTdruy+Clu2/VnN2fTxjEJQXiGKXQtW2e5tX5V2q5Bf5Pn +WTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to :references:mime-version; bh=cJ55pS2zCQ/J6yyrgfUByQHKsTBsW6N4W1N9+lzzch8=; b=Qjdn7kVDyPo/9nhPo1MDG392+/2El1x7t/XAYB2XuHbeouvvGk28iYtkgm9ubgx0qj 5jLLl1AIx8saZD1Az452DDFASNhrOMUJ1i6JhUDY51eYGeWSlTuToCTDYsmmOu1EuD5N cwvAYjQKD5MjVj+6ajzplzYnlT42jEjncRARq9zNiP+vUq1tiyjnOx76qNjcxT0/4PH8 C+XOdrA/Xc1uOO1UITfEG7PFLvOvBZ++FOOpmeHijXOtKpLmMEQuRjQlYNd08P3s8wol sw8UKJEIKl99W+OVeBmZpaJ/g4MoTJgbgLuprKFwUNjpeCq43XAXGvSafzvld9eyWxP+ BMaA== X-Gm-Message-State: AHYfb5jlP9JOdf4WbY+iz4GBk+LHD+IE0WpX/JLy5dTUHagqwJ2Xnr5O /WCBHXu7jvnw3Q== X-Received: by 10.46.64.79 with SMTP id n76mr9284213lja.108.1502793236793; Tue, 15 Aug 2017 03:33:56 -0700 (PDT) Received: from [192.168.100.9] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id n72sm1546938lje.51.2017.08.15.03.33.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Aug 2017 03:33:55 -0700 (PDT) Date: Tue, 15 Aug 2017 12:33:53 +0200 From: Simen =?iso-8859-1?q?Heggest=F8yl?= Subject: Re: bug#27881: New major mode: Less mode To: Stefan Monnier Message-Id: <1502793233.29571.1@smtp.gmail.com> In-Reply-To: References: <1501437183.13205.0@smtp.gmail.com> <1501782658.6810.1@smtp.gmail.com> <=?UTF-8?Q?1501782658.6810.1@smtp.gmail.com> <1502405602.1756.4@smtp.gmail.com> <"Simen =?windows-1252?Q?H?= =?windows-1252?Q?eggest=F8yl=22's?= message of "Fri, 11 Aug 2017 00:53:22 +0200"> X-Mailer: geary/0.11.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 27881-done Cc: 27881-done@debbugs.gnu.org, steve@sanityinc.com, Tom Tromey , dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) Installed. Thanks again! -- Simen ------------=_1502793302-9022-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 30 Jul 2017 17:53:36 +0000 Received: from localhost ([127.0.0.1]:34502 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dbsPD-0002a6-OC for submit@debbugs.gnu.org; Sun, 30 Jul 2017 13:53:35 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45006) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dbsPB-0002Zt-FL for submit@debbugs.gnu.org; Sun, 30 Jul 2017 13:53:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dbsP3-0004qP-Az for submit@debbugs.gnu.org; Sun, 30 Jul 2017 13:53:24 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:37987) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dbsP3-0004px-6X for submit@debbugs.gnu.org; Sun, 30 Jul 2017 13:53:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dbsP0-0000Ke-6W for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2017 13:53:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dbsOw-0004lF-1o for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2017 13:53:18 -0400 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]:35381) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dbsOr-0004gT-Jn for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2017 13:53:13 -0400 Received: by mail-lf0-x243.google.com with SMTP id w199so10787252lff.2 for ; Sun, 30 Jul 2017 10:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:mime-version; bh=MJRyAqXX6fMkX94FuSbdK2pB2lVmwX5p2ZKu1jOaqoE=; b=etVju6Wg2B9GvyMAS1VeHN4UyjuNdjbZeq5iSsqregfNtgbZHfte7DCaLIxSWTe7vx A1uS6Aw63Lt6hAzvzfaWid1VjiuLDWnTNJGXIJjnqmzxqYMjqNy86Jnl7A5l/i34ftzr 0oZJzTv6eX/5LMuSVJFUw3C703J75S90dt6qo04CFDEnyN735RtHZlnjBwg3iI7w9yIh CBbPnsU53vIpO5wD2Z97IzoyhsWdXLSykawfF8+7O0xtZpQRtPDRJV5EQadgHy/E6AhT wcY9eFcYn9+R4WrnDB2IPWJFn/7kAA2Mt5bekmn2j3Me4yQhZsW/LxZRkc+ffE8lE8b4 DBmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:mime-version; bh=MJRyAqXX6fMkX94FuSbdK2pB2lVmwX5p2ZKu1jOaqoE=; b=XbqWIMgxzKy8vk8mhhUtPnxp4oLS//5uBtiaMVd4JJK7nuMsBSNMfL9immGONARZl/ M4wa7JWWqKM/kXAgExyvqDe4u8hyVd+DhbqlTxBPBuXkNURjay2mhq6H6MVVGa+70r2J f0wduSrqgSPQSAwgCannyMnH0CTbfIafnjjtvO1zxH+exdfdVOYM1b32FNM0eVq2BdeU 1uZMyiMAA83YZQ1oAeqte5fPKack5RHL//0h8Mg6kzaHZJKJ0fEHRDjsOWvcA8anIJR+ nz4cjFiHEuv34HfK43C/pWw5gG5Ev55DWyRuDk0qLjJVrV/AX0rmG92rQXBtuE0tqOyp +kKw== X-Gm-Message-State: AIVw113lrxg1ee5p2xsyftDSZg3xITuFSz3k+VXQhUgeYsRDtuEIiz4c m2yTPMRbJ1/Rd3mI X-Received: by 10.25.199.77 with SMTP id x74mr4515810lff.196.1501437186053; Sun, 30 Jul 2017 10:53:06 -0700 (PDT) Received: from [192.168.100.10] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id m5sm5030493lfm.82.2017.07.30.10.53.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 30 Jul 2017 10:53:05 -0700 (PDT) Date: Sun, 30 Jul 2017 19:53:03 +0200 From: Simen =?iso-8859-1?q?Heggest=F8yl?= Subject: New major mode: Less mode To: bug-gnu-emacs@gnu.org Message-Id: <1501437183.13205.0@smtp.gmail.com> X-Mailer: geary/0.11.3 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-p4GrjrrZxOwb/2G34Bou" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit Cc: Steve Purcell , Tom Tromey , Stefan Monnier , Dmitry Gutov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --=-p4GrjrrZxOwb/2G34Bou Content-Type: text/plain; charset=utf-8; format=flowed Hi. Steve Purcell has developed a very nice major mode for editing Less files (a minor variant of CSS). Seeing that Emacs' built-in CSS mode got extended to support SCSS (another minor CSS variant) three years ago, I contacted Steve and asked if he'd like Less mode to become a part of Emacs as well, which he agreed to. I've attached two patches which merge Steve's Less mode into css-mode.el. The first patch is a verbatim copy of Steve's code, the second one contains minor cleanups made by me. The biggest change I've made is to rename the mode from "Less CSS mode" to just "Less mode". I think the renaming has two advantages: Aligning its name with "SCSS mode", and making the mode's commands, variables and function names shorter. The downside is that existing users of Less mode will have to update their config files. Maybe aliasing `less-css-mode' to `less-mode' could help some in that regard. What do you think of it? If this looks okay, I'll complete the patches (fix the commit messages and make a NEWS entry), install them, and start maintaining Less mode as part of css-mode.el. -- Simen --=-p4GrjrrZxOwb/2G34Bou Content-Type: multipart/mixed; boundary="=-d1bLGzGfoMm57wbQ/H2A" --=-d1bLGzGfoMm57wbQ/H2A Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-WIP-New-major-mode-Less-mode-a-minor-variant-of-CSS.patch >From 343b15f8c95ccbd935b5b715b8127d16bd4d7e84 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 12 Jun 2017 22:06:46 +0200 Subject: [PATCH 1/2] WIP: New major mode: Less mode (a minor variant of CSS) --- lisp/textmodes/css-mode.el | 228 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 227 insertions(+), 1 deletion(-) diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 19cb7b4fea..c1ed44b984 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -32,9 +32,10 @@ ;;; Code: -(require 'eww) (require 'cl-lib) (require 'color) +(require 'compile) +(require 'eww) (require 'seq) (require 'sgml-mode) (require 'smie) @@ -1558,6 +1559,231 @@ scss-mode +;;; Less mode +;; +;; This mode provides syntax highlighting for LESS CSS files, plus +;; optional support for compilation of .less files to .css files at +;; the time they are saved: use `less-css-compile-at-save' to enable +;; this. +;; +;; Command line utility "lessc" is required if setting +;; `less-css-compile-at-save' to t. To install "lessc" using the +;; Node.js package manager, run "npm install less" +;; +;; Also make sure the "lessc" executable is in Emacs' PATH, example: +;; (setq exec-path (cons (expand-file-name "~/.gem/ruby/1.8/bin") exec-path)) +;; or customize `less-css-lessc-command' to point to your "lessc" +;; executable. +;; +;; We target lessc >= 1.4.0, and thus use the `--no-color' flag by +;; default. You may want to adjust `less-css-lessc-options' for +;; compatibility with older versions. +;; +;; `less-css-mode' is derived from `css-mode', and indentation of +;; nested blocks may not work correctly with versions of `css-mode' +;; other than that bundled with recent Emacs. +;; +;; You can specify per-file values for `less-css-compile-at-save', +;; `less-css-output-file-name' or `less-css-output-directory' using a +;; variables header at the top of your .less file, e.g.: +;; +;; // -*- less-css-compile-at-save: t; less-css-output-directory: "../css" -*- +;; +;; Alternatively, you can use directory local variables to set the +;; default value of `less-css-output-directory' for your project. +;; +;; In the case of files which are included in other .less files, you +;; may want to trigger the compilation of a "master" .less file on +;; save: you can accomplish this with `less-css-input-file-name', +;; which is probably best set using directory local variables. +;; +;; If you don't need CSS output but would like to be warned of any +;; syntax errors in your .less source, consider using `flymake-less': +;; https://github.com/purcell/flymake-less +;; +;;; Credits +;; +;; The original code for this mode was, in large part, written using +;; Anton Johansson's scss-mode as a template -- thanks Anton! +;; https://github.com/antonj + +(defgroup less-css nil + "Less-css mode" + :prefix "less-css-" + :group 'css) + +;;;###autoload +(defcustom less-css-lessc-command "lessc" + "Command used to compile LESS files. +Should be lessc or the complete path to your lessc executable, + e.g.: \"~/.gem/ruby/1.8/bin/lessc\"" + :type 'file + :group 'less-css + :safe 'stringp) + +;;;###autoload +(defcustom less-css-compile-at-save nil + "If non-nil, the LESS buffers will be compiled to CSS after each save." + :type 'boolean + :group 'less-css + :safe 'booleanp) + +;;;###autoload +(defcustom less-css-lessc-options '("--no-color") + "Command line options for less executable. + +Use \"-x\" to minify output." + :type '(repeat string) + :group 'less-css + :safe t) + +;;;###autoload +(defcustom less-css-output-directory nil + "Directory in which to save CSS, or nil to use the LESS file's directory. + +This path is expanded relative to the directory of the LESS file +using `expand-file-name', so both relative and absolute paths +will work as expected." + :type 'directory + :group 'less-css + :safe 'stringp) + +;;;###autoload +(defcustom less-css-output-file-name nil + "File name in which to save CSS, or nil to use .css for .less. + +This can be also be set to a full path, or a relative path. If +the path is relative, it will be relative to the value of +`less-css-output-dir', if set, or the current directory by +default." + :type 'file + :group 'less-css + :safe 'stringp) +(make-variable-buffer-local 'less-css-output-file-name) + +;;;###autoload +(defcustom less-css-input-file-name nil + "File name which will be compiled to CSS. + +When the current buffer is saved `less-css-input-file-name' file +will be compiled to css instead of the current file. + +Set this in order to trigger compilation of a \"master\" .less +file which includes the current file. The best way to set this +variable in most cases is likely to be via directory local +variables. + +This can be also be set to a full path, or a relative path. If +the path is relative, it will be relative to the the current directory by +default." + :type 'file + :group 'less-css + :safe 'stringp) +(make-variable-buffer-local 'less-css-input-file-name) + +(defconst less-css-default-error-regex + "^\\(?:\e\\[31m\\)?\\([^\e\n]*\\|FileError:.*\n\\)\\(?:\e\\[39m\e\\[31m\\)? in \\(?:\e\\[39m\\)?\\([^ \r\n\t\e]+\\)\\(?:\e\\[90m\\)?\\(?::\\| on line \\)\\([0-9]+\\)\\(?::\\|, column \\)\\([0-9]+\\):?\\(?:\e\\[39m\\)?") + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Compilation to CSS +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(add-to-list 'compilation-error-regexp-alist-alist + (list 'less-css less-css-default-error-regex 2 3 4 nil 1)) +(add-to-list 'compilation-error-regexp-alist 'less-css) + + +(defun less-css-compile-maybe () + "Run `less-css-compile' if `less-css-compile-at-save' is non-nil." + (if less-css-compile-at-save + (less-css-compile))) + +(defun less-css--output-path () + "Calculate the path for the compiled CSS file created by `less-css-compile'." + (expand-file-name (or less-css-output-file-name + (concat (file-name-nondirectory (file-name-sans-extension buffer-file-name)) ".css")) + (or less-css-output-directory default-directory))) + +(defun less-css--maybe-shell-quote-command (command) + "Selectively shell-quote COMMAND appropriately for `system-type'." + (funcall (if (eq system-type 'windows-nt) + 'identity + 'shell-quote-argument) command)) + +;;;###autoload +(defun less-css-compile () + "Compiles the current buffer to css using `less-css-lessc-command'." + (interactive) + (message "Compiling less to css") + (let ((compilation-buffer-name-function (lambda (mode-name) "*less-css-compilation*"))) + (save-window-excursion + (with-current-buffer + (compile + (mapconcat 'identity + (append (list (less-css--maybe-shell-quote-command less-css-lessc-command)) + (mapcar 'shell-quote-argument less-css-lessc-options) + (list (shell-quote-argument + (or less-css-input-file-name buffer-file-name)) + (shell-quote-argument (less-css--output-path)))) + " ")) + (add-hook 'compilation-finish-functions + (lambda (buf msg) + (unless (string-match-p "^finished" msg) + (display-buffer buf))) + nil + t))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Minor mode +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; TODO: interpolation ("@{val}"), escaped values (~"..."), JS eval (~`...`), custom faces +(defconst less-css-font-lock-keywords + '(;; Variables + ("@[a-z_-][a-z-_0-9]*" . font-lock-constant-face) + ("&" . font-lock-preprocessor-face) + ;; Mixins + ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" . (1 font-lock-keyword-face))) + ) + +;;;###autoload +(define-derived-mode less-css-mode css-mode "LESS" + "Major mode for editing LESS files, http://lesscss.org/ +Special commands: +\\{less-css-mode-map}" + (font-lock-add-keywords nil less-css-font-lock-keywords) + ;; cpp-style comments + (modify-syntax-entry ?/ ". 124b" less-css-mode-syntax-table) + (modify-syntax-entry ?* ". 23" less-css-mode-syntax-table) + (modify-syntax-entry ?\n "> b" less-css-mode-syntax-table) + ;; Special chars that sometimes come at the beginning of words. + (modify-syntax-entry ?. "'" less-css-mode-syntax-table) + + (set (make-local-variable 'comment-start) "//") + (set (make-local-variable 'comment-end) "") + (set (make-local-variable 'indent-line-function) 'less-css-indent-line) + (when (functionp 'css-smie-rules) + (smie-setup css-smie-grammar #'css-smie-rules + :forward-token #'css-smie--forward-token + :backward-token #'css-smie--backward-token)) + + (add-hook 'after-save-hook 'less-css-compile-maybe nil t)) + +(define-key less-css-mode-map "\C-c\C-c" 'less-css-compile) + +(defun less-css-indent-line () + "Indent current line according to LESS CSS indentation rules." + (let ((css-navigation-syntax-table less-css-mode-syntax-table)) + (if (fboundp 'css-indent-line) + (css-indent-line) + (smie-indent-line)))) + +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.less\\'" . less-css-mode)) + + + (defvar css--mdn-lookup-history nil) (defcustom css-lookup-url-format -- 2.13.2 --=-d1bLGzGfoMm57wbQ/H2A Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-WIP-Fixes-and-tweaks-for-the-new-Less-mode.patch >From 30d4e2a4b5bb80765e2efa0ef9eba547cc079f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= Date: Mon, 12 Jun 2017 22:15:51 +0200 Subject: [PATCH 2/2] WIP: Fixes and tweaks for the new Less mode --- lisp/textmodes/css-mode.el | 232 +++++++++++++++++++++------------------------ 1 file changed, 109 insertions(+), 123 deletions(-) diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index c1ed44b984..67b786622b 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1561,41 +1561,42 @@ scss-mode ;;; Less mode ;; +;; Originally authored by Steve Purcell. +;; ;; This mode provides syntax highlighting for LESS CSS files, plus ;; optional support for compilation of .less files to .css files at -;; the time they are saved: use `less-css-compile-at-save' to enable -;; this. +;; the time they are saved: use `less-compile-at-save' to enable this. ;; ;; Command line utility "lessc" is required if setting -;; `less-css-compile-at-save' to t. To install "lessc" using the -;; Node.js package manager, run "npm install less" +;; `less-compile-at-save' to t. To install "lessc" using the Node.js +;; package manager, run "npm install less". ;; ;; Also make sure the "lessc" executable is in Emacs' PATH, example: -;; (setq exec-path (cons (expand-file-name "~/.gem/ruby/1.8/bin") exec-path)) -;; or customize `less-css-lessc-command' to point to your "lessc" -;; executable. +;; (setq exec-path (cons (expand-file-name "~/.gem/ruby/1.8/bin") +;; exec-path)) or customize `less-lessc-command' to point to your +;; "lessc" executable. ;; ;; We target lessc >= 1.4.0, and thus use the `--no-color' flag by -;; default. You may want to adjust `less-css-lessc-options' for +;; default. You may want to adjust `less-lessc-options' for ;; compatibility with older versions. ;; -;; `less-css-mode' is derived from `css-mode', and indentation of -;; nested blocks may not work correctly with versions of `css-mode' -;; other than that bundled with recent Emacs. +;; `less-mode' is derived from `css-mode', and indentation of nested +;; blocks may not work correctly with versions of `css-mode' other +;; than that bundled with recent Emacs. ;; -;; You can specify per-file values for `less-css-compile-at-save', -;; `less-css-output-file-name' or `less-css-output-directory' using a +;; You can specify per-file values for `less-compile-at-save', +;; `less-output-file-name' or `less-output-directory' using a ;; variables header at the top of your .less file, e.g.: ;; -;; // -*- less-css-compile-at-save: t; less-css-output-directory: "../css" -*- +;; // -*- less-compile-at-save: t; less-output-directory: "../css" -*- ;; ;; Alternatively, you can use directory local variables to set the -;; default value of `less-css-output-directory' for your project. +;; default value of `less-output-directory' for your project. ;; ;; In the case of files which are included in other .less files, you ;; may want to trigger the compilation of a "master" .less file on -;; save: you can accomplish this with `less-css-input-file-name', -;; which is probably best set using directory local variables. +;; save: you can accomplish this with `less-input-file-name', which is +;; probably best set using directory local variables. ;; ;; If you don't need CSS output but would like to be warned of any ;; syntax errors in your .less source, consider using `flymake-less': @@ -1607,66 +1608,61 @@ scss-mode ;; Anton Johansson's scss-mode as a template -- thanks Anton! ;; https://github.com/antonj -(defgroup less-css nil - "Less-css mode" - :prefix "less-css-" +(defgroup less nil + "Less CSS mode" + :prefix "less-" :group 'css) ;;;###autoload -(defcustom less-css-lessc-command "lessc" - "Command used to compile LESS files. -Should be lessc or the complete path to your lessc executable, - e.g.: \"~/.gem/ruby/1.8/bin/lessc\"" +(defcustom less-lessc-command "lessc" + "Command used to compile Less files. +Should be \"lessc\" or the complete path to your lessc executable, +e.g.: \"~/.gem/ruby/1.8/bin/lessc\"." :type 'file - :group 'less-css + :group 'less :safe 'stringp) ;;;###autoload -(defcustom less-css-compile-at-save nil - "If non-nil, the LESS buffers will be compiled to CSS after each save." +(defcustom less-compile-at-save nil + "If non-nil, Less buffers are compiled to CSS after each save." :type 'boolean - :group 'less-css + :group 'less :safe 'booleanp) ;;;###autoload -(defcustom less-css-lessc-options '("--no-color") - "Command line options for less executable. - +(defcustom less-lessc-options '("--no-color") + "Command line options for Less executable. Use \"-x\" to minify output." :type '(repeat string) - :group 'less-css + :group 'less :safe t) ;;;###autoload -(defcustom less-css-output-directory nil - "Directory in which to save CSS, or nil to use the LESS file's directory. - -This path is expanded relative to the directory of the LESS file +(defcustom less-output-directory nil + "Directory in which to save CSS, or nil to use the Less file's directory. +This path is expanded relative to the directory of the Less file using `expand-file-name', so both relative and absolute paths will work as expected." :type 'directory - :group 'less-css + :group 'less :safe 'stringp) ;;;###autoload -(defcustom less-css-output-file-name nil +(defcustom less-output-file-name nil "File name in which to save CSS, or nil to use .css for .less. - This can be also be set to a full path, or a relative path. If the path is relative, it will be relative to the value of -`less-css-output-dir', if set, or the current directory by -default." +`less-output-dir', if set, or the current directory by default." :type 'file - :group 'less-css + :group 'less :safe 'stringp) -(make-variable-buffer-local 'less-css-output-file-name) +(make-variable-buffer-local 'less-output-file-name) ;;;###autoload -(defcustom less-css-input-file-name nil +(defcustom less-input-file-name nil "File name which will be compiled to CSS. - -When the current buffer is saved `less-css-input-file-name' file -will be compiled to css instead of the current file. +When the current buffer is saved `less-input-file-name' file will +be compiled to CSS instead of the current file. Set this in order to trigger compilation of a \"master\" .less file which includes the current file. The best way to set this @@ -1674,59 +1670,61 @@ less-css-input-file-name variables. This can be also be set to a full path, or a relative path. If -the path is relative, it will be relative to the the current directory by -default." +the path is relative, it will be relative to the the current +directory by default." :type 'file - :group 'less-css + :group 'less :safe 'stringp) -(make-variable-buffer-local 'less-css-input-file-name) +(make-variable-buffer-local 'less-input-file-name) -(defconst less-css-default-error-regex +(defconst less-default-error-regex "^\\(?:\e\\[31m\\)?\\([^\e\n]*\\|FileError:.*\n\\)\\(?:\e\\[39m\e\\[31m\\)? in \\(?:\e\\[39m\\)?\\([^ \r\n\t\e]+\\)\\(?:\e\\[90m\\)?\\(?::\\| on line \\)\\([0-9]+\\)\\(?::\\|, column \\)\\([0-9]+\\):?\\(?:\e\\[39m\\)?") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Compilation to CSS -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (add-to-list 'compilation-error-regexp-alist-alist - (list 'less-css less-css-default-error-regex 2 3 4 nil 1)) -(add-to-list 'compilation-error-regexp-alist 'less-css) - - -(defun less-css-compile-maybe () - "Run `less-css-compile' if `less-css-compile-at-save' is non-nil." - (if less-css-compile-at-save - (less-css-compile))) - -(defun less-css--output-path () - "Calculate the path for the compiled CSS file created by `less-css-compile'." - (expand-file-name (or less-css-output-file-name - (concat (file-name-nondirectory (file-name-sans-extension buffer-file-name)) ".css")) - (or less-css-output-directory default-directory))) - -(defun less-css--maybe-shell-quote-command (command) + (list 'less less-default-error-regex 2 3 4 nil 1)) +(add-to-list 'compilation-error-regexp-alist 'less) + +(defun less-compile-maybe () + "Run `less-compile' if `less-compile-at-save' is non-nil." + (when less-compile-at-save + (less-compile))) + +(defun less--output-path () + "Return the path to use for the compiled CSS file." + (expand-file-name + (or less-output-file-name + (concat + (file-name-nondirectory + (file-name-sans-extension buffer-file-name)) + ".css")) + (or less-output-directory default-directory))) + +(defun less--maybe-shell-quote-command (command) "Selectively shell-quote COMMAND appropriately for `system-type'." (funcall (if (eq system-type 'windows-nt) 'identity - 'shell-quote-argument) command)) + 'shell-quote-argument) + command)) ;;;###autoload -(defun less-css-compile () - "Compiles the current buffer to css using `less-css-lessc-command'." +(defun less-compile () + "Compile the current buffer to CSS using `less-lessc-command'." (interactive) - (message "Compiling less to css") - (let ((compilation-buffer-name-function (lambda (mode-name) "*less-css-compilation*"))) + (message "Compiling Less to CSS") + (let ((compilation-buffer-name-function + (lambda (_) "*less-compilation*"))) (save-window-excursion (with-current-buffer (compile - (mapconcat 'identity - (append (list (less-css--maybe-shell-quote-command less-css-lessc-command)) - (mapcar 'shell-quote-argument less-css-lessc-options) - (list (shell-quote-argument - (or less-css-input-file-name buffer-file-name)) - (shell-quote-argument (less-css--output-path)))) - " ")) + (string-join + (append (list (less--maybe-shell-quote-command less-lessc-command)) + (mapcar 'shell-quote-argument less-lessc-options) + (list (shell-quote-argument + (or less-input-file-name buffer-file-name)) + (shell-quote-argument (less--output-path)))) + " ")) (add-hook 'compilation-finish-functions (lambda (buf msg) (unless (string-match-p "^finished" msg) @@ -1734,53 +1732,41 @@ less-css-compile nil t))))) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Minor mode -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;; TODO: interpolation ("@{val}"), escaped values (~"..."), JS eval (~`...`), custom faces -(defconst less-css-font-lock-keywords +;; TODO: +;; - interpolation ("@{val}") +;; - escaped values (~"...") +;; - JavaScript eval (~`...`) +;; - custom faces +(defconst less-font-lock-keywords '(;; Variables - ("@[a-z_-][a-z-_0-9]*" . font-lock-constant-face) + ("@[a-z_-][a-z-_0-9]*" . font-lock-variable-name-face) ("&" . font-lock-preprocessor-face) ;; Mixins - ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" . (1 font-lock-keyword-face))) - ) + ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" . + (1 font-lock-keyword-face)))) + +(defvar less-mode-syntax-table + (let ((st (make-syntax-table css-mode-syntax-table))) + ;; C++-style comments. + (modify-syntax-entry ?/ ". 124b" st) + (modify-syntax-entry ?* ". 23" st) + (modify-syntax-entry ?\n "> b" st) + ;; Special chars that sometimes come at the beginning of words. + (modify-syntax-entry ?. "'" st) + st)) +;;;###autoload (add-to-list 'auto-mode-alist '("\\.less\\'" . less-mode)) ;;;###autoload -(define-derived-mode less-css-mode css-mode "LESS" - "Major mode for editing LESS files, http://lesscss.org/ +(define-derived-mode less-mode css-mode "Less" + "Major mode for editing Less files, http://lesscss.org/ Special commands: -\\{less-css-mode-map}" - (font-lock-add-keywords nil less-css-font-lock-keywords) - ;; cpp-style comments - (modify-syntax-entry ?/ ". 124b" less-css-mode-syntax-table) - (modify-syntax-entry ?* ". 23" less-css-mode-syntax-table) - (modify-syntax-entry ?\n "> b" less-css-mode-syntax-table) - ;; Special chars that sometimes come at the beginning of words. - (modify-syntax-entry ?. "'" less-css-mode-syntax-table) - - (set (make-local-variable 'comment-start) "//") - (set (make-local-variable 'comment-end) "") - (set (make-local-variable 'indent-line-function) 'less-css-indent-line) - (when (functionp 'css-smie-rules) - (smie-setup css-smie-grammar #'css-smie-rules - :forward-token #'css-smie--forward-token - :backward-token #'css-smie--backward-token)) - - (add-hook 'after-save-hook 'less-css-compile-maybe nil t)) - -(define-key less-css-mode-map "\C-c\C-c" 'less-css-compile) - -(defun less-css-indent-line () - "Indent current line according to LESS CSS indentation rules." - (let ((css-navigation-syntax-table less-css-mode-syntax-table)) - (if (fboundp 'css-indent-line) - (css-indent-line) - (smie-indent-line)))) +\\{less-mode-map}" + (font-lock-add-keywords nil less-font-lock-keywords) + (setq-local comment-start "//") + (setq-local comment-end "") + (add-hook 'after-save-hook 'less-compile-maybe nil t)) -;;;###autoload -(add-to-list 'auto-mode-alist '("\\.less\\'" . less-css-mode)) +(define-key less-mode-map "\C-c\C-c" 'less-compile) -- 2.13.2 --=-d1bLGzGfoMm57wbQ/H2A-- --=-p4GrjrrZxOwb/2G34Bou-- ------------=_1502793302-9022-1--