emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 5130a95 2/2: Merge branch 'master' of git.sv.gnu.or


From: Michael Albinus
Subject: [Emacs-diffs] master 5130a95 2/2: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Date: Thu, 18 Jul 2019 14:46:49 -0400 (EDT)

branch: master
commit 5130a95cd187bb67aea7252edb334a470bc3cf79
Merge: 12d6abb b4eaa7e
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
---
 lisp/progmodes/asm-mode.el            | 24 ++++++------
 test/lisp/progmodes/asm-mode-tests.el | 72 +++++++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+), 13 deletions(-)

diff --git a/lisp/progmodes/asm-mode.el b/lisp/progmodes/asm-mode.el
index d6e1559..017a5b5 100644
--- a/lisp/progmodes/asm-mode.el
+++ b/lisp/progmodes/asm-mode.el
@@ -1,4 +1,4 @@
-;;; asm-mode.el --- mode for editing assembler code
+;;; asm-mode.el --- mode for editing assembler code  -*- lexical-binding: t; 
-*-
 
 ;; Copyright (C) 1991, 2001-2019 Free Software Foundation, Inc.
 
@@ -54,8 +54,7 @@
 
 (defcustom asm-comment-char ?\;
   "The `comment-start' character assumed by Asm mode."
-  :type 'character
-  :group 'asm)
+  :type 'character)
 
 (defvar asm-mode-syntax-table
   (let ((st (make-syntax-table)))
@@ -127,10 +126,10 @@ Turning on Asm mode runs the hook `asm-mode-hook' at the 
end of initialization.
 Special commands:
 \\{asm-mode-map}"
   (setq local-abbrev-table asm-mode-abbrev-table)
-  (set (make-local-variable 'font-lock-defaults) '(asm-font-lock-keywords))
-  (set (make-local-variable 'indent-line-function) 'asm-indent-line)
+  (setq-local font-lock-defaults '(asm-font-lock-keywords))
+  (setq-local indent-line-function #'asm-indent-line)
   ;; Stay closer to the old TAB behavior (was tab-to-tab-stop).
-  (set (make-local-variable 'tab-always-indent) nil)
+  (setq-local tab-always-indent nil)
 
   (run-hooks 'asm-mode-set-comment-hook)
   ;; Make our own local child of asm-mode-map
@@ -140,12 +139,11 @@ Special commands:
   (set-syntax-table (make-syntax-table asm-mode-syntax-table))
   (modify-syntax-entry asm-comment-char "< b")
 
-  (set (make-local-variable 'comment-start) (string asm-comment-char))
-  (set (make-local-variable 'comment-add) 1)
-  (set (make-local-variable 'comment-start-skip)
-       "\\(?:\\s<+\\|/[/*]+\\)[ \t]*")
-  (set (make-local-variable 'comment-end-skip) "[ \t]*\\(\\s>\\|\\*+/\\)")
-  (set (make-local-variable 'comment-end) "")
+  (setq-local comment-start (string asm-comment-char))
+  (setq-local comment-add 1)
+  (setq-local comment-start-skip "\\(?:\\s<+\\|/[/*]+\\)[ \t]*")
+  (setq-local comment-end-skip "[ \t]*\\(\\s>\\|\\*+/\\)")
+  (setq-local comment-end "")
   (setq fill-prefix "\t"))
 
 (defun asm-indent-line ()
@@ -172,7 +170,7 @@ Special commands:
    ;; Simple `;' comments go to the comment-column.
    (and (looking-at "\\s<\\(\\S<\\|\\'\\)") comment-column)
    ;; The rest goes at the first tab stop.
-   (or (indent-next-tab-stop 0))))
+   (indent-next-tab-stop 0)))
 
 (defun asm-colon ()
   "Insert a colon; if it follows a label, delete the label's indentation."
diff --git a/test/lisp/progmodes/asm-mode-tests.el 
b/test/lisp/progmodes/asm-mode-tests.el
new file mode 100644
index 0000000..a10add0
--- /dev/null
+++ b/test/lisp/progmodes/asm-mode-tests.el
@@ -0,0 +1,72 @@
+;;; asm-mode-tests.el --- Tests for asm-mode.el  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2019 Free Software Foundation, Inc.
+
+;; Author: Simen Heggestøyl <address@hidden>
+;; Keywords:
+
+;; 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 <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'asm-mode)
+(require 'ert)
+
+(defmacro asm-mode-tests--with-temp-buffer (&rest body)
+  "Create a temporary Asm mode buffer and evaluate BODY there."
+  (declare (indent 0))
+  `(with-temp-buffer
+     (let ((asm-comment-char ?\;))
+       (asm-mode)
+       ,@body)))
+
+(ert-deftest asm-mode-tests-colon ()
+  (asm-mode-tests--with-temp-buffer
+    (let ((indent-tabs-mode t))
+      (insert "\t  label")
+      (let ((last-command-event ?:))
+        (asm-colon))
+      (should (equal (buffer-string) "label:\t")))))
+
+(ert-deftest asm-mode-tests-colon-inside-comment ()
+  (asm-mode-tests--with-temp-buffer
+    (insert ";comment")
+    (let ((last-command-event ?:))
+      (asm-colon))
+    (should (equal (buffer-string) ";comment:"))))
+
+(ert-deftest asm-mode-tests-comment ()
+  (asm-mode-tests--with-temp-buffer
+    (insert "label:")
+    (goto-char (point-min))
+    ;; First invocation
+    (asm-comment)
+    (should (string-match-p "label:[ \t]+;" (buffer-string)))
+    (should (= (current-column) (+ comment-column 1)))
+    ;; Second invocation
+    (asm-comment)
+    (should (string-match-p "[ \t]+;; \nlabel:" (buffer-string)))
+    (should (= (current-column) (+ tab-width 3)))
+    ;; Third invocation
+    (asm-comment)
+    (should (string-match-p ";;; \nlabel:" (buffer-string)))
+    (should (= (current-column) 4))))
+
+;;; asm-mode-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]