diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4bbec93 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,16 @@ +name: Test +on: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install Emacs + run: sudo apt-get install -y emacs-nox + - name: Byte-compile + run: | + emacs --batch --eval '(setq byte-compile-error-on-warn t)' \ + --eval '(add-to-list (quote load-path) ".")' \ + -f batch-byte-compile M2*.el M2-symbols.el.gz diff --git a/M2-symbols.el.gz b/M2-symbols.el.gz index 9827519..34169e5 100644 Binary files a/M2-symbols.el.gz and b/M2-symbols.el.gz differ diff --git a/M2-symbols.el.in b/M2-symbols.el.in index 6775abe..ae93e89 100644 --- a/M2-symbols.el.in +++ b/M2-symbols.el.in @@ -5,15 +5,14 @@ '( @M2SYMBOLS@ ) "A list of the symbols available in Macaulay2, for use with dynamic completion." ) -(let ((max-specpdl-size 1000)) ; needed for passing long long lists to regexp-opt - (defconst M2-keyword-regexp (regexp-opt '( @M2KEYWORDS@ ) 'words) - "Regular expression for Macaulay2 keywords") - (defconst M2-type-regexp (regexp-opt '( @M2DATATYPES@ ) 'words) - "Regular expression for Macaulay2 types") - (defconst M2-function-regexp (regexp-opt '( @M2FUNCTIONS@ ) 'words) - "Regular expression for Macaulay2 functions") - (defconst M2-constant-regexp (regexp-opt '( @M2CONSTANTS@ ) 'words) - "Regular expression for Macaulay2 constants")) +(defconst M2-keyword-regexp (regexp-opt '( @M2KEYWORDS@ ) 'words) + "Regular expression for Macaulay2 keywords") +(defconst M2-type-regexp (regexp-opt '( @M2DATATYPES@ ) 'words) + "Regular expression for Macaulay2 types") +(defconst M2-function-regexp (regexp-opt '( @M2FUNCTIONS@ ) 'words) + "Regular expression for Macaulay2 functions") +(defconst M2-constant-regexp (regexp-opt '( @M2CONSTANTS@ ) 'words) + "Regular expression for Macaulay2 constants") (defconst M2-comint-prompt-regexp "^\\([ \t]*\\(i*[1-9][0-9]* :\\|o*[1-9][0-9]* =\\) \\)?" "Regular expression for the Macaulay2 prompt") diff --git a/M2.el b/M2.el index e7423ec..c2b4bec 100644 --- a/M2.el +++ b/M2.el @@ -45,6 +45,40 @@ ;; M2-comint-mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defvar M2-error-regexp-alist + '( + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; printMessage (stdiop.d) ;; + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; error messages, e.g., + ;; i1 : load "packages/Macaulay2Doc/demo1.m2"; g 2 + ;; packages/Macaulay2Doc/demo1.m2:8:12:(3):[2]: error: division by zero + ;; (1 1) (2 2) (3 3) + ("\\(?:\\(?1:[[:alnum:]/._][[:alnum:]/._-]*\\)\\|\"\\(?1:.+\\)\"\\):\\([0-9]+\\):\\([0-9]+\\):([0-9]+):\\[[0-9]+\\]" + 1 2 3) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; net(FilePosition) (debugging.m2) ;; + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; start & end line/column numbers, e.g.,: + ;; i1 : locate (rank, Matrix) + ;; o1 = m2/matrix1.m2:663:19-666:20 + ;; (1 1) (2 2) (3 3) (4 4) (5 5) + ("\\(?:\\(?1:[[:alnum:]/._][[:alnum:]/._-]*\\)\\|\"\\(?1:.+\\)\"\\):\\([0-9]+\\):\\([0-9]+\\)-\\([0-9]+\\):\\([0-9]+\\)" + 1 (2 . 4) (3 . 5) 0) + ;; no end line/column numbers, e.g.,: + ;; i2 : locate makeDocumentTag rank + ;; o2 = ../Macaulay2Doc/functions/rank-doc.m2:34:0 + ;; (1 1) (2 2) (3 3) + ("\\(?:\\(?1:[[:alnum:]/._][[:alnum:]/._-]*\\)\\|\"\\(?1:.+\\)\"\\):\\([0-9]+\\):\\([0-9]+\\)" + 1 2 3 0)) + "Regular expressions for matching file positions in Macaulay2 output.") + +(defvar M2-transform-file-match-alist + '(("^stdio$" nil) + ("^currentString$" nil) + ("^[0-9][0-9]$" nil)) + "List of filenames not to match in Macaulay2 output.") + ;;;###autoload (define-derived-mode M2-comint-mode comint-mode "Macaulay2 Interaction" "Major mode for interacting with a Macaulay2 process.\n\n\\{M2-comint-mode-map}" @@ -126,12 +160,13 @@ ;; menus -(setq M2-common-menu +(defvar M2-common-menu '(["Match previous bracketed input" M2-match-previous-bracketed-input] ["Match next bracketed input" M2-match-next-bracketed-input] ["Set demo buffer" M2-set-demo-buffer] ["Switch to demo buffer" M2-switch-to-demo-buffer] - ["Start demo" M2-demo])) + ["Start demo" M2-demo]) + "Common parts of menus for both `M2-mode' and `M2-comint-mode'.") (easy-menu-define M2-menu M2-mode-map "Menu for Macaulay2 major mode" @@ -346,40 +381,6 @@ can be executed with \\[M2-send-to-program]." (re-search-backward "<<<") (match-end 0)))) -(defvar M2-error-regexp-alist - '( - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;; printMessage (stdiop.d) ;; - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;; error messages, e.g., - ;; i1 : load "packages/Macaulay2Doc/demo1.m2"; g 2 - ;; packages/Macaulay2Doc/demo1.m2:8:12:(3):[2]: error: division by zero - ;; (1 1) (2 2) (3 3) - ("\\(?:\\(?1:[[:alnum:]/._][[:alnum:]/._-]*\\)\\|\"\\(?1:.+\\)\"\\):\\([0-9]+\\):\\([0-9]+\\):([0-9]+):\\[[0-9]+\\]" - 1 2 3) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;; net(FilePosition) (debugging.m2) ;; - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;; start & end line/column numbers, e.g.,: - ;; i1 : locate (rank, Matrix) - ;; o1 = m2/matrix1.m2:663:19-666:20 - ;; (1 1) (2 2) (3 3) (4 4) (5 5) - ("\\(?:\\(?1:[[:alnum:]/._][[:alnum:]/._-]*\\)\\|\"\\(?1:.+\\)\"\\):\\([0-9]+\\):\\([0-9]+\\)-\\([0-9]+\\):\\([0-9]+\\)" - 1 (2 . 4) (3 . 5) 0) - ;; no end line/column numbers, e.g.,: - ;; i2 : locate makeDocumentTag rank - ;; o2 = ../Macaulay2Doc/functions/rank-doc.m2:34:0 - ;; (1 1) (2 2) (3 3) - ("\\(?:\\(?1:[[:alnum:]/._][[:alnum:]/._-]*\\)\\|\"\\(?1:.+\\)\"\\):\\([0-9]+\\):\\([0-9]+\\)" - 1 2 3 0)) - "Regular expressions for matching file positions in Macaulay2 output.") - -(defvar M2-transform-file-match-alist - '(("^stdio$" nil) - ("^currentString$" nil) - ("^[0-9][0-9]$" nil)) - "List of filenames not to match in Macaulay2 output.") - (define-obsolete-function-alias 'M2-send-input 'comint-send-input "1.23") @@ -465,6 +466,13 @@ for more." (M2--send-to-program-helper send-to-buffer start end)) (forward-paragraph)) +(defvar M2-demo-buffer + (with-current-buffer (get-buffer-create "*M2-demo-buffer*") + (M2-mode) + (current-buffer)) + "The buffer from which lines are obtained by `M2-get-input-from-demo-buffer'. +Set it with `M2-set-demo-buffer'." ) + (defun M2-set-demo-buffer() "Set the variable M2-demo-buffer to the current buffer, so that later, `M2-get-input-from-demo-buffer' can obtain lines from this buffer." @@ -527,6 +535,8 @@ Otherwise, send the input to Macaulay2." (substring string end)) string)) +(declare-function compilation-forget-errors "compile") + (defun M2-comint-forget-errors (string) "Run `compilation-forget-errors' to flush compilation mode's cache. Otherwise, jumping to source will go to the wrong location when a file has @@ -614,13 +624,6 @@ line based on the depth of the parentheses in the code." (M2-this-line-indent-amount)) (delete-horizontal-space)))) -(defvar M2-demo-buffer - (with-current-buffer (get-buffer-create "*M2-demo-buffer*") - (M2-mode) - (current-buffer)) - "The buffer from which lines are obtained by `M2-get-input-from-demo-buffer'. -Set it with `M2-set-demo-buffer'." ) - ;;; "blink" evaluated region (heavily inspired by ESS) (defcustom M2-blink-region-flag t