From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#14732: Package dos-mode for ELPA Date: Wed, 07 Aug 2013 13:27:19 -0400 Message-ID: References: <83y59qb4xz.fsf@gnu.org> <83bo59v5pj.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1375896497 10041 80.91.229.3 (7 Aug 2013 17:28:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 7 Aug 2013 17:28:17 +0000 (UTC) Cc: arnima@hafro.is, 14732@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Aug 07 19:28:17 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1V77Wz-0000np-6n for geb-bug-gnu-emacs@m.gmane.org; Wed, 07 Aug 2013 19:28:17 +0200 Original-Received: from localhost ([::1]:42431 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V77Wy-0001b6-G2 for geb-bug-gnu-emacs@m.gmane.org; Wed, 07 Aug 2013 13:28:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V77Wq-0001a0-CG for bug-gnu-emacs@gnu.org; Wed, 07 Aug 2013 13:28:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V77Wl-0005J0-2k for bug-gnu-emacs@gnu.org; Wed, 07 Aug 2013 13:28:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51545) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V77Wk-0005Iw-VU for bug-gnu-emacs@gnu.org; Wed, 07 Aug 2013 13:28:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1V77Wk-0002Rc-Gj for bug-gnu-emacs@gnu.org; Wed, 07 Aug 2013 13:28: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: Wed, 07 Aug 2013 17:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14732 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 14732-submit@debbugs.gnu.org id=B14732.13758964509310 (code B ref 14732); Wed, 07 Aug 2013 17:28:02 +0000 Original-Received: (at 14732) by debbugs.gnu.org; 7 Aug 2013 17:27:30 +0000 Original-Received: from localhost ([127.0.0.1]:45858 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V77WC-0002Q0-T9 for submit@debbugs.gnu.org; Wed, 07 Aug 2013 13:27:29 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:7788) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V77WA-0002PS-4W for 14732@debbugs.gnu.org; Wed, 07 Aug 2013 13:27:26 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFLd/Nq/2dsb2JhbABEvw4Xc4IeAQEEAVYjEAs0EhQYDSQTiAsGwS2RCgOSWwOSHIFegxM X-IPAS-Result: Av4EABK/CFFLd/Nq/2dsb2JhbABEvw4Xc4IeAQEEAVYjEAs0EhQYDSQTiAsGwS2RCgOSWwOSHIFegxM X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="20859342" Original-Received: from 75-119-243-106.dsl.teksavvy.com (HELO pastel.home) ([75.119.243.106]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 07 Aug 2013 13:27:13 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id B328F66AF2; Wed, 7 Aug 2013 13:27:19 -0400 (EDT) In-Reply-To: <83bo59v5pj.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 07 Aug 2013 19:14:16 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:77035 Archived-At: >> OK, so I just installed your code into trunk. Thank you. >> I also added the patch below to it. > I found no patch attached. What are you, blind? Look again! Stefan "Geez!" === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-08-07 15:43:57 +0000 +++ lisp/ChangeLog 2013-08-07 15:50:16 +0000 @@ -1,3 +1,10 @@ +2013-08-07 Stefan Monnier + + * progmodes/dos.el (auto-mode-alist): Add entries for dos-mode. + (dos-mode): Use setq-local. Add space after "rem". + (dos-mode-syntax-table): Don't use "w" for symbol chars. + (dos-font-lock-keywords): Try to adjust font-lock rules accordingly. + 2013-08-07 Arni Magnusson * progmodes/dos.el: New file. === modified file 'lisp/progmodes/dos.el' --- lisp/progmodes/dos.el 2013-08-07 15:43:57 +0000 +++ lisp/progmodes/dos.el 2013-08-07 15:50:16 +0000 @@ -79,24 +79,25 @@ "goto" "gtr" "if" "in" "leq" "lss" "neq" "not" "start")) (LINUX '("cat" "cp" "ls" "mv" "rm"))) - (list - '("\\<\\(call\\|goto\\)\\>[ \t]+%?\\([A-Za-z0-9-_\\:.]+\\)%?" + `(("\\<_\\(call\\|goto\\)\\_>[ \t]+%?\\([A-Za-z0-9-_\\:.]+\\)%?" (2 font-lock-constant-face t)) - '("^[ \t]*\\(@?rem\\>\\|::\\).*" + ("^[ \t]*\\(@?rem\\_>\\|::\\).*" (0 font-lock-comment-face t)) - '("^:[^:].*" + ("^:[^:].*" . 'dos-label-face) - '("\\<\\(defined\\|set\\)\\>[ \t]*\\(\\w+\\)" + ("\\<_\\(defined\\|set\\)\\_>[ \t]*\\(\\w+\\)" (2 font-lock-variable-name-face)) - '("%\\(\\w+\\)%?" + ("%\\(\\w+\\)%?" (1 font-lock-variable-name-face)) - '("!\\(\\w+\\)!?" ; delayed-expansion !variable! + ("!\\(\\w+\\)!?" ; delayed-expansion !variable! (1 font-lock-variable-name-face)) - '("[ =][-/]+\\(\\w+\\)" + ("[ =][-/]+\\(\\w+\\)" (1 font-lock-type-face append)) - (cons (regexp-opt COMMANDS 'words) font-lock-builtin-face) - (cons (regexp-opt CONTROLFLOW 'words) font-lock-keyword-face) - (cons (regexp-opt LINUX 'words) font-lock-warning-face))))) + (,(concat "\\_<" (regexp-opt COMMANDS) "\\_>") . font-lock-builtin-face) + (,(concat "\\_<" (regexp-opt CONTROLFLOW) "\\_>") + . font-lock-keyword-face) + (,(concat "\\_<" (regexp-opt LINUX) "\\_>") + . font-lock-warning-face))))) (defvar dos-menu '("Dos" @@ -114,7 +115,7 @@ (let ((map (make-sparse-keymap))) (easy-menu-define nil map nil dos-menu) (define-key map [?\C-c ?\C-.] 'dos-mode-help) - (define-key map [?\C-c ?\C-/] 'dos-cmd-help) + (define-key map [?\C-c ?\C-/] 'dos-cmd-help) ;FIXME: Why not C-c C-? ? (define-key map [?\C-c ?\C-a] 'dos-run-args) (define-key map [?\C-c ?\C-c] 'dos-run) (define-key map [?\C-c ?\C-t] 'dos-template) @@ -123,21 +124,24 @@ (defvar dos-mode-syntax-table (let ((table (make-syntax-table))) - (modify-syntax-entry ?~ "w" table) + ;; Beware: `w' should not be used for non-alphabetic chars. + (modify-syntax-entry ?~ "_" table) (modify-syntax-entry ?% "." table) - (modify-syntax-entry ?- "w" table) - (modify-syntax-entry ?_ "w" table) - (modify-syntax-entry ?{ "w" table) - (modify-syntax-entry ?} "w" table) + (modify-syntax-entry ?- "_" table) + (modify-syntax-entry ?_ "_" table) + ;; FIXME: { and } can appear in identifiers? Really? + (modify-syntax-entry ?{ "_" table) + (modify-syntax-entry ?} "_" table) (modify-syntax-entry ?\\ "." table) table)) ;; 4 User functions (defun dos-cmd-help (cmd) - "Show help for Dos command." + "Show help for Dos command CMD." (interactive "sHelp: ") (if (string-equal cmd "net") + ;; FIXME: liable to quoting nightmare. Use call-process? (shell-command "net /?") (shell-command (concat "help " cmd)))) (defun dos-mode-help () @@ -149,11 +153,13 @@ (defun dos-run () "Run Dos script." (interactive) + ;; FIXME: liable to quoting nightmare. Use call/start-process? (save-buffer) (shell-command buffer-file-name)) (defun dos-run-args (args) "Run Dos script with ARGS." (interactive "sArgs: ") + ;; FIXME: Use `compile'? (shell-command (concat buffer-file-name " " args))) (defun dos-template () @@ -161,6 +167,9 @@ (interactive) (goto-char (point-min)) (insert "@echo off\nsetlocal\n\n")) +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.\\(bat\\|cmd\\)\\'" . dos-mode)) + ;; 5 Main function ;;;###autoload @@ -171,12 +180,11 @@ `dos-cmd-help'. Navigate between sections using `imenu'. Run script using `dos-run' and `dos-run-args'.\n \\{dos-mode-map}" - (set (make-local-variable 'comment-start) "rem") - (set (make-local-variable 'font-lock-defaults) + (setq-local comment-start "rem ") + (setq-local font-lock-defaults '(dos-font-lock-keywords nil t)) ; case-insensitive keywords - (set (make-local-variable 'imenu-generic-expression) '((nil "^:[^:].*" 0))) - (set (make-local-variable 'outline-regexp) ":[^:]") - (set-syntax-table dos-mode-syntax-table)) + (setq-local imenu-generic-expression '((nil "^:[^:].*" 0))) + (setq-local outline-regexp ":[^:]")) (provide 'dos)