From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#27881: New major mode: Less mode Date: Sun, 30 Jul 2017 16:59:57 -0400 Message-ID: References: <1501437183.13205.0@smtp.gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1501453401 4375 195.159.176.226 (30 Jul 2017 22:23:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 30 Jul 2017 22:23:21 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: steve@sanityinc.com, tom@tromey.com, 27881@debbugs.gnu.org, dgutov@yandex.ru To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jul 31 00:23:13 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dbwcC-0000NJ-9y for geb-bug-gnu-emacs@m.gmane.org; Mon, 31 Jul 2017 00:23:12 +0200 Original-Received: from localhost ([::1]:56611 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dbwcB-0002yR-Ec for geb-bug-gnu-emacs@m.gmane.org; Sun, 30 Jul 2017 18:23:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52392) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dbwc6-0002x7-0B for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2017 18:23:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dbwc2-0003yN-Q3 for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2017 18:23:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60153) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dbwc2-0003yH-NL for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2017 18:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dbwc2-0002Qd-Hh for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2017 18:23:02 -0400 X-Loop: help-debbugs@gnu.org 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: X-Debbugs-Original-Cc: Steve Purcell , bug-gnu-emacs@gnu.org, Tom Tromey , Dmitry Gutov Original-Received: via spool by submit@debbugs.gnu.org id=B.15014533819314 (code B ref -1); Sun, 30 Jul 2017 22:23:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Jul 2017 22:23:01 +0000 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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 Original-Received: by ceviche.home (Postfix, from userid 20848) id 5F8B366129; Sun, 30 Jul 2017 16:59:57 -0400 (EDT) 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") 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:135177 Archived-At: 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'.