2019-11-27 20:30:14 +01:00
|
|
|
;;; matlab-maint.el --- matlab mode maintainer utilities
|
|
|
|
;;
|
|
|
|
;; Copyright (C) 2019 Eric Ludlam
|
|
|
|
;;
|
|
|
|
;; Author: Eric Ludlam <eludlam@emacsvm>
|
|
|
|
;;
|
|
|
|
;; This program 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.
|
|
|
|
|
|
|
|
;; This program 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 this program. If not, see https://www.gnu.org/licenses/.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;;
|
|
|
|
;; Interface for maintainers of matlab mode.
|
|
|
|
|
|
|
|
(require 'matlab)
|
|
|
|
(require 'matlab-shell)
|
2019-12-08 20:03:46 +01:00
|
|
|
(require 'matlab-netshell)
|
2021-03-20 20:10:58 +01:00
|
|
|
(require 'semantic/symref)
|
|
|
|
(require 'semantic/symref/list)
|
2019-11-27 20:30:14 +01:00
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
;;; Minor Mode Definition
|
|
|
|
;;
|
cedet-matlab.el, matlab-cgen.el, matlab-compat.el,
matlab-complete.el, matlab-maint.el, matlab-netshell.el,
matlab-publish.el, matlab-topic.el, semantic-matlab.el,
semanticdb-matlab.el, srecode-matlab.el:
Fix varous issues in doc strings and messages identified by `checkdoc'
command.
2019-12-13 04:36:55 +01:00
|
|
|
(defvar matlab-maint-mode-map
|
2019-11-27 20:30:14 +01:00
|
|
|
(let ((km (make-sparse-keymap)))
|
2021-03-20 20:10:58 +01:00
|
|
|
;; compile debug cycle
|
2019-11-27 20:30:14 +01:00
|
|
|
(define-key km [f8] 'matlab-maint-run-tests)
|
|
|
|
(define-key km [f9] 'matlab-maint-compile-matlab-emacs)
|
2021-03-25 02:36:21 +01:00
|
|
|
(define-key km [f10] 'matlab-maint-reload-mode)
|
2021-03-20 20:10:58 +01:00
|
|
|
;; coding
|
|
|
|
(define-key km [f7] 'matlab-maint-symref-this)
|
|
|
|
;; matlab
|
|
|
|
(define-key km [f5] 'matlab-maint-show-info)
|
2019-11-27 20:30:14 +01:00
|
|
|
km)
|
|
|
|
"Keymap used by matlab mode maintainers.")
|
|
|
|
|
|
|
|
(easy-menu-define
|
|
|
|
matlab-maint-menu matlab-maint-mode-map "MATLAB Maintainer's Minor Mode"
|
|
|
|
'("MMaint"
|
2019-11-29 21:42:03 +01:00
|
|
|
["Compile" matlab-maint-compile-matlab-emacs t]
|
2019-12-22 23:01:38 +01:00
|
|
|
["Clean" matlab-maint-compile-clean t]
|
2019-11-27 20:30:14 +01:00
|
|
|
["Run Tests" matlab-maint-run-tests t]
|
2019-12-22 23:01:38 +01:00
|
|
|
["Pick Emacs to run" matlab-maint-pick-emacs t]
|
2019-11-29 21:42:03 +01:00
|
|
|
["Toggle IO Logging" matlab-maint-toggle-io-tracking
|
|
|
|
:style toggle :selected matlab-shell-io-testing ]
|
2019-12-08 20:03:46 +01:00
|
|
|
["Display logger frame" matlab-maint-toggle-logger-frame
|
|
|
|
:style toggle :selected (and matlab-maint-logger-frame
|
|
|
|
(frame-live-p matlab-maint-logger-frame)) ]
|
2019-11-27 20:30:14 +01:00
|
|
|
))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(define-minor-mode matlab-maint-minor-mode
|
|
|
|
"Minor mode for matlab-mode maintainrs."
|
|
|
|
nil " MMaint" matlab-maint-mode-map
|
|
|
|
)
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(define-global-minor-mode global-matlab-maint-minor-mode
|
|
|
|
matlab-maint-minor-mode
|
|
|
|
(lambda ()
|
|
|
|
"Should we turn on in this buffer? Only if in the project."
|
|
|
|
(let ((dir (expand-file-name default-directory))
|
|
|
|
(ml (file-name-directory (expand-file-name (locate-library "matlab")))))
|
|
|
|
(when (string= ml (substring dir 0 (min (length dir) (length ml))))
|
|
|
|
(matlab-maint-minor-mode 1))))
|
|
|
|
)
|
|
|
|
|
2021-03-20 20:10:58 +01:00
|
|
|
;;; Testing stuff in M buffers
|
|
|
|
;;
|
|
|
|
(defun matlab-maint-show-info ()
|
|
|
|
"Show info about line in current matlab buffer."
|
|
|
|
(interactive)
|
|
|
|
(when (eq major-mode 'matlab-mode)
|
|
|
|
(matlab-show-line-info)
|
|
|
|
))
|
|
|
|
|
|
|
|
;;; HACKING ELISP
|
|
|
|
;;
|
|
|
|
|
|
|
|
(defun matlab-maint-symref-this ()
|
|
|
|
"Open a symref buffer on symbol under cursor."
|
|
|
|
(interactive)
|
2021-03-21 01:57:04 +01:00
|
|
|
(save-buffer)
|
2021-03-20 20:10:58 +01:00
|
|
|
(semantic-fetch-tags)
|
|
|
|
(let ((ct (semantic-current-tag)))
|
|
|
|
;; Must have a tag...
|
|
|
|
(when (not ct) (error "Place cursor inside tag to be searched for"))
|
|
|
|
;; Gather results and tags
|
|
|
|
(message "Gathering References for %s.." (semantic-tag-name ct))
|
|
|
|
(let* ((name (semantic-tag-name ct))
|
|
|
|
(res (semantic-symref-find-references-by-name name)))
|
|
|
|
(semantic-symref-produce-list-on-results res name)
|
|
|
|
(semantic-symref-list-expand-all) )))
|
|
|
|
|
|
|
|
|
|
|
|
;;; COMPILE AND TEST
|
2019-11-27 20:30:14 +01:00
|
|
|
;;
|
|
|
|
;; Helpful commands for maintainers.
|
2019-12-22 23:01:38 +01:00
|
|
|
(defcustom matlab-maint-compile-opts '("emacs" "emacs24" "emacs25" "emacs26")
|
|
|
|
"Various emacs versions we can use to compile with."
|
|
|
|
:group 'matlab-maint
|
|
|
|
:type '(repeat (string :tag "Emacs Command: ")))
|
|
|
|
|
|
|
|
(defcustom matlab-maint-compile-emacs "emacs"
|
|
|
|
"The EMACS to pass into make."
|
|
|
|
:group 'matlab-maint
|
|
|
|
:type 'string)
|
|
|
|
|
|
|
|
(defun matlab-maint-pick-emacs (emacscmd)
|
|
|
|
"Select the Emacs to use for compiling."
|
|
|
|
(interactive (list (completing-read "Emacs to compile MATLAB: "
|
|
|
|
matlab-maint-compile-opts
|
|
|
|
nil
|
|
|
|
t
|
|
|
|
(car matlab-maint-compile-opts))))
|
|
|
|
(setq matlab-maint-compile-emacs emacscmd)
|
|
|
|
)
|
2019-11-27 20:30:14 +01:00
|
|
|
|
|
|
|
(defun matlab-maint-compile-matlab-emacs ()
|
|
|
|
"Run make for the matlab-emacs project."
|
|
|
|
(interactive)
|
|
|
|
(save-excursion
|
|
|
|
(matlab-maint-set-buffer-to "matlab.el")
|
2019-12-22 23:01:38 +01:00
|
|
|
(if (string= matlab-maint-compile-emacs "emacs")
|
|
|
|
(compile "make")
|
|
|
|
(compile (concat "make EMACS=" matlab-maint-compile-emacs))))
|
|
|
|
)
|
|
|
|
|
|
|
|
(defun matlab-maint-compile-clean ()
|
|
|
|
"Run make for the matlab-emacs project."
|
|
|
|
(interactive)
|
|
|
|
(save-excursion
|
|
|
|
(matlab-maint-set-buffer-to "matlab.el")
|
|
|
|
(compile "make clean")
|
|
|
|
))
|
2019-11-27 20:30:14 +01:00
|
|
|
|
|
|
|
(defun matlab-maint-run-tests (arg)
|
|
|
|
"Run the tests for matlab mode.
|
cedet-matlab.el, matlab-cgen.el, matlab-compat.el,
matlab-complete.el, matlab-maint.el, matlab-netshell.el,
matlab-publish.el, matlab-topic.el, semantic-matlab.el,
semanticdb-matlab.el, srecode-matlab.el:
Fix varous issues in doc strings and messages identified by `checkdoc'
command.
2019-12-13 04:36:55 +01:00
|
|
|
With universal ARG, ask for the code to be run with output tracking turned on."
|
2019-11-27 20:30:14 +01:00
|
|
|
(interactive "P")
|
2021-03-26 23:43:13 +01:00
|
|
|
(when (buffer-file-name)
|
|
|
|
(save-buffer))
|
2019-11-27 20:30:14 +01:00
|
|
|
(save-excursion
|
|
|
|
(matlab-maint-set-buffer-to "tests/Makefile")
|
2019-12-17 23:26:58 +01:00
|
|
|
(if (or arg matlab-shell-io-testing)
|
2019-11-27 20:30:14 +01:00
|
|
|
;; Ask for dbug
|
|
|
|
(compile "make TESTDEBUG=1")
|
|
|
|
;; No debugging
|
|
|
|
(compile "make")))
|
|
|
|
(switch-to-buffer "*compilation*")
|
|
|
|
(delete-other-windows)
|
|
|
|
(goto-char (point-max)))
|
|
|
|
|
2021-03-25 02:36:21 +01:00
|
|
|
(defun matlab-maint-reload-mode ()
|
|
|
|
"Reload matlab mode, and refresh displayed ML buffers modes."
|
|
|
|
(interactive)
|
|
|
|
(load-library "matlab-syntax")
|
|
|
|
(load-library "matlab-scan")
|
|
|
|
(load-library "matlab")
|
|
|
|
(mapc (lambda (b) (with-current-buffer b
|
|
|
|
(when (eq major-mode 'matlab-mode)
|
|
|
|
(message "Updating matlab mode in %S" b)
|
|
|
|
(matlab-mode))))
|
|
|
|
(buffer-list (selected-frame)))
|
|
|
|
(message "loading done")
|
|
|
|
)
|
2021-03-20 20:10:58 +01:00
|
|
|
;;; MATLAB SHELL tools
|
|
|
|
;;
|
2019-11-27 20:30:14 +01:00
|
|
|
|
|
|
|
(defun matlab-maint-set-buffer-to (file)
|
|
|
|
"Set the current buffer to FILE found in matlab-mode's source.
|
|
|
|
Return the buffer."
|
|
|
|
(let* ((ml (file-name-directory (locate-library "matlab")))
|
|
|
|
(newf (expand-file-name file ml)))
|
|
|
|
(set-buffer (find-file-noselect newf))))
|
|
|
|
|
2019-11-29 21:42:03 +01:00
|
|
|
(defun matlab-maint-toggle-io-tracking ()
|
|
|
|
"Toggle tracking of IO with MATLAB Shell."
|
|
|
|
(interactive)
|
|
|
|
(setq matlab-shell-io-testing (not matlab-shell-io-testing))
|
|
|
|
(message "MATLAB Shell IO logging %s" (if matlab-shell-io-testing
|
|
|
|
"enabled" "disabled")))
|
|
|
|
|
2019-12-08 20:03:46 +01:00
|
|
|
(defvar matlab-maint-logger-frame nil
|
|
|
|
"Frame displaying log information.")
|
|
|
|
|
|
|
|
(defun matlab-maint-toggle-logger-frame ()
|
|
|
|
"Display a frame showing various log buffers."
|
|
|
|
(interactive)
|
|
|
|
(if (and matlab-maint-logger-frame
|
|
|
|
(frame-live-p matlab-maint-logger-frame))
|
|
|
|
(progn
|
|
|
|
(delete-frame matlab-maint-logger-frame)
|
|
|
|
(setq matlab-maint-logger-frame nil))
|
|
|
|
;; Otherwise, create ...
|
|
|
|
(setq matlab-maint-logger-frame (make-frame))
|
|
|
|
(with-selected-frame matlab-maint-logger-frame
|
|
|
|
(delete-other-windows)
|
|
|
|
(switch-to-buffer "*Messages*")
|
2019-12-09 04:10:18 +01:00
|
|
|
(when (matlab-netshell-client)
|
|
|
|
(split-window-horizontally)
|
|
|
|
(other-window 1)
|
|
|
|
(switch-to-buffer (process-buffer (matlab-netshell-client)))
|
|
|
|
))))
|
2019-11-29 21:42:03 +01:00
|
|
|
|
2019-11-27 20:30:14 +01:00
|
|
|
(provide 'matlab-maint)
|
|
|
|
|
|
|
|
;;; matlab-maint.el ends here
|