Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix byte-compilation warnings #74

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
Binary file modified M2-symbols.el.gz
Binary file not shown.
17 changes: 8 additions & 9 deletions M2-symbols.el.in
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
89 changes: 46 additions & 43 deletions M2.el
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down