[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 614c82c3c0 1/2: Added error notices
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 614c82c3c0 1/2: Added error notices |
Date: |
Mon, 23 May 2022 10:33:51 -0400 (EDT) |
branch: externals/phps-mode
commit 614c82c3c09fc08c615f1b595a2162281cb43dcd
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Added error notices
---
phps-mode-lex-analyzer.el | 158 ++++++++++++++++++++++++++--------------------
phps-mode.el | 22 +++++++
2 files changed, 113 insertions(+), 67 deletions(-)
diff --git a/phps-mode-lex-analyzer.el b/phps-mode-lex-analyzer.el
index 010d4b2098..73dce8050a 100644
--- a/phps-mode-lex-analyzer.el
+++ b/phps-mode-lex-analyzer.el
@@ -42,6 +42,15 @@
(defvar-local phps-mode-lex-analyzer--processed-buffer-p nil
"Flag whether current buffer is processed or not.")
+(defvar-local phps-mode-lex-analyzer--error-end nil
+ "Point of error end or nil.")
+
+(defvar-local phps-mode-lex-analyzer--error-message nil
+ "Message of error.")
+
+(defvar-local phps-mode-lex-analyzer--error-start nil
+ "Point of error start or nil.")
+
;; VARIABLES
@@ -217,6 +226,7 @@
(setq async nil))
(phps-mode-serial-commands
+
buffer-name
(lambda()
@@ -295,29 +305,31 @@
(phps-mode-lex-analyzer--reset-changes)
;; Signal parser error (if any)
- (when phps-mode-lex-analyzer--parse-error
-
- ;; Paint error
- (phps-mode-lex-analyzer--set-region-syntax-color
- (nth 4 phps-mode-lex-analyzer--parse-error)
- (point-max)
- (list 'font-lock-face 'font-lock-warning-face))
-
- ;; Display error
- (display-warning
- 'phps-mode
- (nth 1 phps-mode-lex-analyzer--parse-error)
- :warning
- "*PHPs Parser Errors*")
-
- ;; Signal that causes updated mode-line status
- (signal
- 'phps-parser-error
- (list
- (nth 1 phps-mode-lex-analyzer--parse-error)
- (nth 4 phps-mode-lex-analyzer--parse-error))))
-
- )))
+ (if phps-mode-lex-analyzer--parse-error
+ (progn
+
+ ;; Paint error
+ (phps-mode-lex-analyzer--set-region-syntax-color
+ (nth 4 phps-mode-lex-analyzer--parse-error)
+ (point-max)
+ (list 'font-lock-face 'font-lock-warning-face))
+
+ ;; Set error
+ (setq phps-mode-lex-analyzer--error-end nil)
+ (setq phps-mode-lex-analyzer--error-message (nth 1
phps-mode-lex-analyzer--parse-error))
+ (setq phps-mode-lex-analyzer--error-start (nth 4
phps-mode-lex-analyzer--parse-error))
+
+ ;; Signal that causes updated mode-line status
+ (signal
+ 'phps-parser-error
+ (list
+ (nth 1 phps-mode-lex-analyzer--parse-error)
+ (nth 4 phps-mode-lex-analyzer--parse-error))))
+
+ ;; Reset error
+ (setq phps-mode-lex-analyzer--error-end nil)
+ (setq phps-mode-lex-analyzer--error-message nil)
+ (setq phps-mode-lex-analyzer--error-start nil)))))
(lambda(result)
(when (get-buffer buffer-name)
@@ -341,24 +353,25 @@
(phps-mode-lex-analyzer--set-region-syntax-color
error-start
(point-max)
- (list 'font-lock-face 'font-lock-warning-face))))
- (display-warning
- 'phps-mode
- error-message
- :warning
- "*PHPs Lexer Errors*"))
+ (list 'font-lock-face 'font-lock-warning-face)))
- (t
- (display-warning
- error-type
- error-message
- :warning))
+ ;; Set error
+ (setq phps-mode-lex-analyzer--error-end (if error-end
error-end nil))
+ (setq phps-mode-lex-analyzer--error-message error-message)
+ (setq phps-mode-lex-analyzer--error-start error-start)))
- )
+ (t
+ (progn
- )
+ ;; Reset error
+ (setq phps-mode-lex-analyzer--error-end nil)
+ (setq phps-mode-lex-analyzer--error-message nil)
+ (setq phps-mode-lex-analyzer--error-start nil)
- ))))
+ (display-warning
+ error-type
+ error-message
+ :warning)))))))))
nil
async
@@ -460,27 +473,31 @@
(phps-mode-lex-analyzer--reset-changes)
;; Signal parser error (if any)
- (when phps-mode-lex-analyzer--parse-error
-
- ;; Paint error
- (phps-mode-lex-analyzer--set-region-syntax-color
- (nth 4 phps-mode-lex-analyzer--parse-error)
- (point-max)
- (list 'font-lock-face 'font-lock-warning-face))
-
- ;; Display error
- (display-warning
- 'phps-mode
- (nth 1 phps-mode-lex-analyzer--parse-error)
- :warning
- "*PHPs Parser Errors*")
-
- ;; Signal that causes updated mode-line status
- (signal
- 'phps-parser-error
- (list
- (nth 1 phps-mode-lex-analyzer--parse-error)
- (nth 4 phps-mode-lex-analyzer--parse-error)))))))
+ (if phps-mode-lex-analyzer--parse-error
+ (progn
+
+ ;; Paint error
+ (phps-mode-lex-analyzer--set-region-syntax-color
+ (nth 4 phps-mode-lex-analyzer--parse-error)
+ (point-max)
+ (list 'font-lock-face 'font-lock-warning-face))
+
+ ;; Set error
+ (setq phps-mode-lex-analyzer--error-end nil)
+ (setq phps-mode-lex-analyzer--error-message (nth 1
phps-mode-lex-analyzer--parse-error))
+ (setq phps-mode-lex-analyzer--error-start (nth 4
phps-mode-lex-analyzer--parse-error))
+
+ ;; Signal that causes updated mode-line status
+ (signal
+ 'phps-parser-error
+ (list
+ (nth 1 phps-mode-lex-analyzer--parse-error)
+ (nth 4 phps-mode-lex-analyzer--parse-error))))
+
+ ;; Reset error
+ (setq phps-mode-lex-analyzer--error-end nil)
+ (setq phps-mode-lex-analyzer--error-message nil)
+ (setq phps-mode-lex-analyzer--error-start nil)))))
(lambda(result)
(when (get-buffer buffer-name)
@@ -506,17 +523,24 @@
error-start
(point-max)
(list 'font-lock-face 'font-lock-warning-face))))
- (display-warning
- 'phps-mode
- error-message
- :warning
- "*PHPs Lexer Errors*"))
+
+ ;; Set error
+ (setq phps-mode-lex-analyzer--error-end (if error-end
error-end nil))
+ (setq phps-mode-lex-analyzer--error-message error-message)
+ (setq phps-mode-lex-analyzer--error-start error-start))
(t
- (display-warning
- error-type
- error-message
- :warning))))))))
+ (progn
+
+ ;; Reset error
+ (setq phps-mode-lex-analyzer--error-end nil)
+ (setq phps-mode-lex-analyzer--error-message nil)
+ (setq phps-mode-lex-analyzer--error-start nil)
+
+ (display-warning
+ error-type
+ error-message
+ :warning)))))))))
nil
async
diff --git a/phps-mode.el b/phps-mode.el
index 438b427eff..d5fc5c6d20 100644
--- a/phps-mode.el
+++ b/phps-mode.el
@@ -73,6 +73,22 @@
map)
"Keymap for `phps-mode'.")
+(defun phps-mode-error-notice ()
+ "Display error notices in echo are if any."
+ (when (and
+ phps-mode-lex-analyzer--error-start
+ phps-mode-lex-analyzer--error-message
+ (>= (point) phps-mode-lex-analyzer--error-start))
+ (let ((display-error))
+ (if phps-mode-lex-analyzer--error-end
+ (when (<= (point) phps-mode-lex-analyzer--error-end)
+ (setq display-error t))
+ (setq display-error t))
+ (when display-error
+ (message
+ "PHPs Error: %s"
+ phps-mode-lex-analyzer--error-message)))))
+
;;;###autoload
(defun phps-mode-rescan-buffer ()
"Re-scan buffer."
@@ -241,6 +257,12 @@
0
t)
+ ;; Support for error notices
+ (run-with-idle-timer
+ phps-mode-idle-interval
+ t
+ #'phps-mode-error-notice)
+
;; Initial run of lexer
(phps-mode-lex-analyzer--re2c-run
nil