[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode 9abad67 273/468: Merge remote-tracking branch 'up
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode 9abad67 273/468: Merge remote-tracking branch 'upstream/master' |
Date: |
Thu, 5 Aug 2021 04:58:51 -0400 (EDT) |
branch: elpa/lua-mode
commit 9abad67db7a2055ea7c9e22887c24f5706777bab
Merge: 8d27d2c 2453e37
Author: xristos <xristos@sdf.lonestar.org>
Commit: xristos <xristos@sdf.lonestar.org>
Merge remote-tracking branch 'upstream/master'
---
Makefile | 4 ++++
lua-mode.el | 22 ++++++++++++------
test/inferior-test.el | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++
test/test-helper.el | 40 ++++++++++++++++++++++++--------
4 files changed, 113 insertions(+), 16 deletions(-)
diff --git a/Makefile b/Makefile
index 48c9385..1c57ce8 100644
--- a/Makefile
+++ b/Makefile
@@ -51,3 +51,7 @@ release:
woger lua-l lua-mode lua-mode "release $(VERSION)" "Emacs major mode
for editing Lua files" release-notes-$(VERSION)
http://github.com/immerrr/lua-mode/ && \
git push origin master
@echo 'Send update to ELPA!'
+
+
+tryout:
+ cask exec $(EMACS) -Q -l lua-mode.el test.lua
diff --git a/lua-mode.el b/lua-mode.el
index 0fd4178..c2e3881 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -383,7 +383,9 @@ If the latter is nil, the keymap translates into
`lua-mode-map' verbatim.")
:group 'lua)
(defcustom lua-traceback-line-re
- "^\\(?:[\t ]*\\|.*>[\t ]+\\)\\([^\n\t ]+\\):\\([0-9]+\\):"
+ ;; This regexp skips prompt and meaningless "stdin:N:" prefix when looking
+ ;; for actual file-line locations.
+ "^\\(?:[\t ]*\\|.*>[\t ]+\\)\\(?:stdin:[0-9]+:[\t
]*\\)?\\(?:stdin:[0-9]+:\\|\\([^\n\t ]*\\):\\([0-9]+\\):\\)"
"Regular expression that describes tracebacks and errors."
:type 'regexp
:group 'lua)
@@ -1640,17 +1642,17 @@ When called interactively, switch to the process
buffer."
(accept-process-output (get-buffer-process (current-buffer)))
(goto-char (point-max)))
;; send initialization code
- (comint-simple-send nil lua-process-init-code)
+ (lua-send-string lua-process-init-code)
;; enable error highlighting in stack traces
(require 'compile)
(make-local-variable 'compilation-error-regexp-alist)
(setq compilation-error-regexp-alist
- (cons '("^\t*\\([^:\n]+\\):\\([^:\n]+\\):" 1 2)
+ (cons (list lua-traceback-line-re 1 2)
;; Remove 'gnu entry from error regexp alist, it somehow forces
;; leading TAB to be recognized as part of filename in Emacs23.
(delq 'gnu compilation-error-regexp-alist)))
- (compilation-shell-minor-mode))
+ (compilation-shell-minor-mode 1))
;; when called interactively, switch to process buffer
(if (lua--called-interactively-p 'any)
@@ -1664,7 +1666,7 @@ When called interactively, switch to the process buffer."
lua-process)
(defun lua-kill-process ()
- "Kill lua subprocess and its buffer."
+ "Kill Lua subprocess and its buffer."
(interactive)
(when (buffer-live-p lua-process-buffer)
(kill-buffer lua-process-buffer)))
@@ -1679,8 +1681,14 @@ When called interactively, switch to the process buffer."
(interactive)
(set-marker lua-region-end (or arg (point))))
+(defun lua-send-string (str)
+ "Send STR plus a newline to Lua subprocess.
+
+If `lua-process' is nil or dead, start a new process first."
+ (comint-simple-send (lua-get-create-process) str))
+
(defun lua-send-current-line ()
- "Send current line to lua subprocess, found in `lua-process'.
+ "Send current line to Lua subprocess, found in `lua-process'.
If `lua-process' is nil or dead, start a new process first."
(interactive)
(lua-send-region (line-beginning-position) (line-end-position)))
@@ -1734,7 +1742,7 @@ Otherwise, return START."
(lua-make-lua-string region-str)
(lua-make-lua-string lua-file)
lineno)))
- (comint-simple-send (lua-get-create-process) command)
+ (lua-send-string command)
(when lua-always-show (lua-show-process-buffer))))
(defun lua-prompt-line ()
diff --git a/test/inferior-test.el b/test/inferior-test.el
index 9e4a35c..8d3bd80 100644
--- a/test/inferior-test.el
+++ b/test/inferior-test.el
@@ -28,3 +28,66 @@
(lua-hide-process-buffer)
(should (get-buffer-window cur-buf)))))
+(ert-deftest lua-runtime-error-msg-is-fontified ()
+ :expected-result (if (eq 23 emacs-major-version) :failed :passed)
+ (with-lua-buffer
+ (insert "\
+function bar()
+ error(123)
+end
+
+function foo()
+ bar()
+end
+")
+ (rename-buffer "test-send-runtime-error.lua" 'unique)
+ ;; By default, basic face for all error messages is 'underline, this is pain
+ ;; to filter out, let's change that to 'default.
+ (let ((compilation-message-face 'default))
+ (lua-send-buffer)
+ (lua-send-string "foo()")
+ ;; Make sure to wait enough to get all the output from the subprocess.
+ (while (accept-process-output lua-process 0 200))
+ (with-current-buffer lua-process-buffer
+ (should
+ (equal
+ ;; (buffer-string)
+ (get-buffer-line-faces)
+ '(nil ;; motd line
+ ("> " comint-highlight-prompt
+ "test-send-runtime-error.lua" compilation-error
+ "2" compilation-line-number) ;; error message
+ nil ;; stack traceback
+ nil ;; in function error
+ ("test-send-runtime-error.lua" compilation-error
+ "2" compilation-line-number) ;; in 'bar'
+ ("test-send-runtime-error.lua" compilation-error
+ "6" compilation-line-number) ;; in 'foo'
+ nil ;; in main chunk
+ nil
+ nil)))))))
+
+
+(ert-deftest lua-syntax-error-msg-is-fontified ()
+ :expected-result (if (eq 23 emacs-major-version) :failed :passed)
+ (with-lua-buffer
+ (rename-buffer "test-send-syntax-error.lua")
+ (insert "\
+foo = 1
+bar = 2
+
+function () end
+")
+ (let ((compilation-message-face 'default))
+ (lua-send-buffer)
+ (while (accept-process-output lua-process 0 200))
+ (with-current-buffer lua-process-buffer
+ (should
+ (equal
+ (get-buffer-line-faces)
+ '(nil
+ ("> " comint-highlight-prompt
+ "test-send-syntax-error.lua" compilation-error
+ "4" compilation-line-number)
+ ;; stacktrace with misc info, no font-lock
+ nil nil nil nil nil nil)))))))
diff --git a/test/test-helper.el b/test/test-helper.el
index 3c407ba..20f1104 100644
--- a/test/test-helper.el
+++ b/test/test-helper.el
@@ -1,6 +1,7 @@
(require 'ert)
(require 'lua-mode)
+
(defun get-str-faces (str)
"Find contiguous spans of non-default faces in STR.
@@ -11,13 +12,25 @@ E.g. for properly fontified Lua string \"local x = 100\" it
should return
"
(let ((pos 0)
nextpos
- result prop)
+ result prop newprop)
(while pos
- (setq nextpos (next-single-property-change pos 'face str)
- prop (get-text-property pos 'face str))
- (when prop
- (push (substring-no-properties str pos nextpos) result)
- (push prop result))
+ (setq nextpos (next-property-change pos str)
+ newprop (or (get-text-property pos 'face str)
+ (get-text-property pos 'font-lock-face str)))
+ (when (not (equal prop newprop))
+ (setq prop newprop)
+
+ (when (listp prop)
+ (when (eq (car-safe (last prop)) 'default)
+ (setq prop (butlast prop)))
+ (when (= 1 (length prop))
+ (setq prop (car prop)))
+ (when (symbolp prop)
+ (when (eq prop 'default)
+ (setq prop nil))))
+ (when prop
+ (push (substring-no-properties str pos nextpos) result)
+ (push prop result)))
(setq pos nextpos))
(nreverse result)))
@@ -29,6 +42,12 @@ E.g. for properly fontified Lua string \"local x = 100\" it
should return
(font-lock-fontify-buffer)
(buffer-string)))
+(defun get-buffer-line-faces ()
+ (font-lock-fontify-buffer)
+ (mapcar 'get-str-faces
+ (split-string (buffer-string) "\n" nil)))
+
+
(defun lua-get-line-faces (str)
"Find contiguous spans of non-default faces in each line of STR.
@@ -59,12 +78,15 @@ This is a mere typing/reading aid for lua-mode's font-lock
tests."
(defmacro with-lua-buffer (&rest body)
`(with-temp-buffer
+ (lua-mode)
(set (make-local-variable 'lua-process) nil)
(set (make-local-variable 'lua-process-buffer) nil)
- (switch-to-buffer (current-buffer))
- (lua-mode)
(font-lock-fontify-buffer)
- ,@body))
+ (pop-to-buffer (current-buffer))
+ (unwind-protect
+ (progn ,@body)
+ (when (buffer-live-p lua-process-buffer)
+ (lua-kill-process)))))
(defun lua-get-indented-strs (strs)
(butlast
- [nongnu] elpa/lua-mode c1b6019 396/468: Fix reproducibility issue caused by %d pattern in export-subst, (continued)
- [nongnu] elpa/lua-mode c1b6019 396/468: Fix reproducibility issue caused by %d pattern in export-subst, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c9b9d47 401/468: Fix typo, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d7eaa8e 403/468: Add lua-backward-up-list command, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode db8d474 408/468: Fix indentation of multiline while/for+do and if/elseif+then, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 099c130 240/468: Bump NEWS, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 7099b81 248/468: Bump tests: fix some, move expected failures to separate test cases, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6a5fa6b 249/468: Remove unused tempfile functionality, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 1a0e191 255/468: lua--rx-symbol: fix shy-grouping, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6f7800f 258/468: Merge (and squash) pull request #66 from rolpereira/master, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 3265552 263/468: indentation-test: add continuation tests for unary ops and ..., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 9abad67 273/468: Merge remote-tracking branch 'upstream/master',
Philip Kaludercic <=
- [nongnu] elpa/lua-mode ec491dd 291/468: lua-process-init-code: use load when loadstring is not available, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d7ccb88 294/468: Add new builtin functions and operators from Lua 5.3, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c0d8c50 295/468: Merge pull request #86 from immerrr/if-loadstring-is-nil-use-load, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 3f7a032 300/468: Move .nosearch in test/, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode ca24f4c 302/468: Add `run-lua` alias, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 530aa9f 303/468: Merge pull request #97 from marsam/master, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 92d9729 307/468: Add init-tryout.el to persistent initialization code, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 04a2772 310/468: Fix goto label fontification, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode fbad628 316/468: Add travis.yml, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6b32777 413/468: assignment statements: unindent closing parenthesis on right hand side, Philip Kaludercic, 2021/08/05