* list/progmodes/idl*.el: Use lexical-binding

* lisp/progmodes/idlw-complete-structtag.el: Use lexical-binding.

* lisp/progmodes/idlw-help.el: Use lexical-binding.
Delete redundant `:group` arguments.
(idlwave-query-class, idlwave-force-class-query, idlw-help-name)
(idlw-help-kwd, idlw-help-link): Declare vars.
(idlwave-highlight-linked-completions): Remove unused var `class`.
(idlwave-help-find-in-doc-header): Remove unused var `header-re`.

* lisp/progmodes/idlw-shell.el (idlwave-shell-input-mode-magic):
Remove XEmacs-only code.
(idlwave-shell-filter, idlwave-shell-scan-for-state):
Use `functionp` since a function can also satisfy `listp`.
(idlwave-shell--mouse-examine): Rename from `idlwave-shell-mouse-examine`.
Make it a function, and simplify for Emacs≥22.  Simplify calling convention
since all callers always immediately `funcall`d the result.
Update all callers.
(idlwave-default-mouse-track-event-is-with-button): Use `always`.
(idlwave-shell-filter-bp): Simplify a tiny bit.

* lisp/progmodes/idlw-toolbar.el: Use lexical-binding.
(idlwave-toolbar-add, idlwave-toolbar-remove)
(idlwave-toolbar-add-everywhere, idlwave-toolbar-remove-everywhere)
(idlwave-toolbar-toggle): Remove XEmacs-only code.

* lisp/progmodes/idlwave.el: Use lexical-binding.
(idlwave--dlet): New macro.
(<toplevel>): Use it.
(idlwave-keyword-abbrev): Turn it into a function.
(idlwave-code-abbrev): Delete macro.
(idlwave-mode-abbrev-table): Use `:enable-function` instead.
(idlwave-with-special-syntax): Delete macro; use `with-syntax-table`
instead in all callers.
(idlwave-action-and-binding): Use `alist-get` and replace `(lambda...)
with a proper closure.  Change all callers to prefer passing a function
in the `cmd` argument.
(idlwave-fill-function): Delete constant var.
Replace its uses with its value (the symbol `auto-fill-function`).
(idlwave-mode): Set `normal-auto-fill-function` instead of the
cumbersome use of `idlwave-fill-function`.  Tighten a regexp.
Don't set `imenu-create-index-function` to the value it should already have.
(idlwave-auto-fill-mode): Make it an obsolete alias for `auto-fill-mode`.
(idlwave-modify-abbrev): Rename from `idlwave-check-abbrev`.
Don't check `idlwave-quoted` since `:enable-function` did it for us already.
(idlwave--command-function): Rename from `idlwave-command-hook`
and make it hold a function rather than an expression.
(idlwave-command-hook, idlwave-modify-abbrev): Adjust accordingly.
(idlwave-show-begin-check): Don't check `idlwave-quoted` since
`:enable-function` did it for us already.
(idlwave-do-action): Use `functionp` since a function can also satisfy `listp`
(idlwave-new-sintern-type): Make it a macro, so we don't need to
`declare-function` for the functions it defines.
(idlwave--class-selector, idlwave--type-selector)
(idlwave--method-selector, idlwave--super-classes): Rename those vars
by adding the `idlwave--` prefix.  Adjust all uses.
(idlwave-complete-functions): Rename from `idlwave-complete-special`.
(idlwave-call-special): Declare obsolete.  Change all callers to use
`run-hook-with-args-until-success` instead.
(idlwave-complete-filename): Use `dlet`.
(idlwave-rinfo-assq-any-class): Remove unused var `class`.
(idlwave-determine-class-functions): Rename from
`idlwave-determine-class-special`; fix docstring since the functions
are called with only one argument.
(idlwave--complete-after-success-function): Rename from
`idlwave-complete-after-success-form` and make it hold a function.
Adjust all users.
(idlwave--complete-after-success-force-function): Rename from
`idlwave-complete-after-success-form-force` and make it hold a function.
Adjust all users.
(idlwave-attach-classes): Remove always-t variable `do-dots`.
(idlwave-local-value): Use `local-variable-p` and `buffer-local-value`
to avoid `with-current-buffer`.
(idlwave-default-choose-completion): Comment out (unused and calls
a function that doesn't exist).
(idlwave-shell-filter-sysvars): Remove unused vars `type`, `name`, and `class`
(idlwave-fix-module-if-obj_new): Remove unused var `name`.
(idlwave-fix-keywords): Bind `idlwave--super-classes` via `let` than
via the function's argument.
(idlwave-twin-class, idlwave-twin-name): Move before first use.
(idlwave-study-twins): Remove stealth/redundant `type` variable.
(idlwave-routine-entry-compare-twins): Remove unused var `type`.
(idlwave-path-alist-add-flag): Avoid `add-to-list` on a local var.
(idlwave-list-abbrevs): Simplify a tiny bit.
This commit is contained in:
Stefan Monnier 2021-03-24 17:11:05 -04:00
parent 3bacf74adb
commit 8e9835c673
5 changed files with 675 additions and 761 deletions

View file

@ -1,4 +1,4 @@
;;; idlw-complete-structtag.el --- Completion of structure tags.
;;; idlw-complete-structtag.el --- Completion of structure tags. -*- lexical-binding: t; -*-
;; Copyright (C) 2001-2021 Free Software Foundation, Inc.
@ -100,12 +100,11 @@
(defvar idlwave-sint-structtags nil)
;; Create the sintern type for structure talks
(declare-function idlwave-sintern-structtag "idlw-complete-structtag" t t)
(idlwave-new-sintern-type 'structtag)
(idlwave-new-sintern-type structtag)
;; Hook the plugin into idlwave
(add-to-list 'idlwave-complete-special 'idlwave-complete-structure-tag)
(add-hook 'idlwave-update-rinfo-hook 'idlwave-structtag-reset)
(add-hook 'idlwave-complete-functions #'idlwave-complete-structure-tag)
(add-hook 'idlwave-update-rinfo-hook #'idlwave-structtag-reset)
;;; The main code follows below
(defvar idlwave-completion-help-info)

View file

@ -1,4 +1,4 @@
;;; idlw-help.el --- HTML Help code for IDLWAVE
;;; idlw-help.el --- HTML Help code for IDLWAVE -*- lexical-binding: t; -*-
;; Copyright (C) 2000-2021 Free Software Foundation, Inc.
;;
@ -50,7 +50,6 @@
(defcustom idlwave-html-help-pre-v6 nil
"Whether pre or post-v6.0 IDL help documents are being used."
:group 'idlwave-online-help
:type 'boolean)
(defvar idlwave-html-link-sep
@ -60,7 +59,6 @@
"The directory, relative to `idlwave-system-directory', where the IDL
HTML help files live, for IDL 6.2 and later. This location, if found,
is used in preference to the old `idlwave-html-help-location'."
:group 'idlwave-online-help
:type 'directory)
(defcustom idlwave-html-help-location
@ -69,7 +67,6 @@ is used in preference to the old `idlwave-html-help-location'."
"/usr/local/etc/")
"The directory where the idl_html_help/ dir lives. Obsolete for IDL
6.2 or later (see `idlwave-html-system-help-location')."
:group 'idlwave-online-help
:type 'directory)
(defvar idlwave-help-use-hh nil
@ -77,18 +74,15 @@ is used in preference to the old `idlwave-html-help-location'."
(defcustom idlwave-help-use-assistant t
"Whether to use the IDL Assistant as the help browser."
:group 'idlwave-online-help
:type 'boolean)
(defcustom idlwave-help-browser-function browse-url-browser-function
"Function to use to display HTML help.
Defaults to `browse-url-browser-function', which see."
:group 'idlwave-online-help
:type 'function)
(defcustom idlwave-help-browser-generic-program browse-url-generic-program
"Program to run if using `browse-url-generic-program'."
:group 'idlwave-online-help
:type '(choice (const nil) string))
;; AFAICS, never used since it was introduced in 2004.
@ -96,7 +90,6 @@ Defaults to `browse-url-browser-function', which see."
(if (boundp 'browse-url-generic-args)
browse-url-generic-args "")
"Program args to use if using `browse-url-generic-program'."
:group 'idlwave-online-help
:type '(repeat string))
(defcustom idlwave-help-browser-is-local nil
@ -106,7 +99,6 @@ external programs. If the browser name contains \"-w3\", it is
assumed to be local to Emacs. For other local browsers, this variable
must be explicitly set non-nil in order for the variable
`idlwave-help-use-dedicated-frame' to function."
:group 'idlwave-online-help
:type 'boolean)
(defvar idlwave-help-directory ""
@ -114,7 +106,6 @@ must be explicitly set non-nil in order for the variable
(defcustom idlwave-help-use-dedicated-frame t
"Non-nil means, use a separate frame for Online Help if possible."
:group 'idlwave-online-help
:type 'boolean)
(defcustom idlwave-help-frame-parameters
@ -123,14 +114,12 @@ must be explicitly set non-nil in order for the variable
See also `idlwave-help-use-dedicated-frame'.
If you do not set the frame width here, the value specified in
`idlw-help.el' will be used."
:group 'idlwave-online-help
:type '(repeat
(cons symbol sexp)))
(defcustom idlwave-max-popup-menu-items 20
"Maximum number of items per pane in popup menus.
Currently only used for class selection during completion help."
:group 'idlwave-online-help
:type 'integer)
(defcustom idlwave-extra-help-function 'idlwave-help-with-source
@ -158,12 +147,10 @@ The default value for this function is `idlwave-help-with-source' which
loads the routine source file into the help buffer. If you try to write
a different function which accesses a special help file or so, it is
probably a good idea to still call this function as a fallback."
:group 'idlwave-online-help
:type 'symbol)
(defcustom idlwave-help-fontify-source-code nil
"Non-nil means, fontify source code displayed as help like normal code."
:group 'idlwave-online-help
:type 'boolean)
(defcustom idlwave-help-source-try-header t
@ -173,7 +160,6 @@ help text. When this variable is non-nil, we try to find a description of
the help item in the first routine doclib header above the routine definition.
If the variable is nil, or if we cannot find/parse the header, the routine
definition is displayed instead."
:group 'idlwave-online-help
:type 'boolean)
@ -181,20 +167,17 @@ definition is displayed instead."
"A regexp for the heading word to search for in doclib headers
which specifies the `name' section. Can be used for localization
support."
:group 'idlwave-online-help
:type 'regexp)
(defcustom idlwave-help-doclib-keyword "KEYWORD"
"A regexp for the heading word to search for in doclib headers
which specifies the `keywords' section. Can be used for localization
support."
:group 'idlwave-online-help
:type 'regexp)
(defface idlwave-help-link
'((t :inherit link))
"Face for highlighting links into IDLWAVE online help."
:group 'idlwave-online-help)
"Face for highlighting links into IDLWAVE online help.")
(defvar idlwave-help-activate-links-aggressively nil
"Obsolete variable.")
@ -219,20 +202,20 @@ support."
(defvar idlwave-help-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "q" 'idlwave-help-quit)
(define-key map "w" 'widen)
(define-key map "q" #'idlwave-help-quit)
(define-key map "w" #'widen)
(define-key map "\C-m" (lambda (arg)
(interactive "p")
(scroll-up arg)))
(define-key map " " 'scroll-up-command)
(define-key map [?\S-\ ] 'scroll-down-command)
(define-key map [delete] 'scroll-down-command)
(define-key map "h" 'idlwave-help-find-header)
(define-key map "H" 'idlwave-help-find-first-header)
(define-key map "." 'idlwave-help-toggle-header-match-and-def)
(define-key map "F" 'idlwave-help-fontify)
(define-key map "\M-?" 'idlwave-help-return-to-calling-frame)
(define-key map "x" 'idlwave-help-return-to-calling-frame)
(define-key map " " #'scroll-up-command)
(define-key map [?\S-\ ] #'scroll-down-command)
(define-key map [delete] #'scroll-down-command)
(define-key map "h" #'idlwave-help-find-header)
(define-key map "H" #'idlwave-help-find-first-header)
(define-key map "." #'idlwave-help-toggle-header-match-and-def)
(define-key map "F" #'idlwave-help-fontify)
(define-key map "\M-?" #'idlwave-help-return-to-calling-frame)
(define-key map "x" #'idlwave-help-return-to-calling-frame)
map)
"The keymap used in `idlwave-help-mode'.")
@ -374,7 +357,7 @@ It collects and prints the diagnostics messages."
(setq idlwave-last-context-help-pos marker)
(idlwave-do-context-help1 arg)
(if idlwave-help-diagnostics
(message "%s" (mapconcat 'identity
(message "%s" (mapconcat #'identity
(nreverse idlwave-help-diagnostics)
"; "))))))
@ -384,6 +367,12 @@ It collects and prints the diagnostics messages."
(defvar idlwave-system-variables-alist)
(defvar idlwave-executive-commands-alist)
(defvar idlwave-system-class-info)
(defvar idlwave-query-class)
(defvar idlwave-force-class-query)
(defvar idlw-help-name)
(defvar idlw-help-kwd)
(defvar idlw-help-link)
(defun idlwave-do-context-help1 (&optional arg)
"The work-horse version of `idlwave-context-help', which see."
(save-excursion
@ -549,16 +538,16 @@ It collects and prints the diagnostics messages."
(setq mod1 (append (list t) module))))
(if mod3
(condition-case nil
(apply 'idlwave-online-help mod1)
(apply #'idlwave-online-help mod1)
(error (condition-case nil
(apply 'idlwave-online-help mod2)
(error (apply 'idlwave-online-help mod3)))))
(apply #'idlwave-online-help mod2)
(error (apply #'idlwave-online-help mod3)))))
(if mod2
(condition-case nil
(apply 'idlwave-online-help mod1)
(error (apply 'idlwave-online-help mod2)))
(apply #'idlwave-online-help mod1)
(error (apply #'idlwave-online-help mod2)))
(if mod1
(apply 'idlwave-online-help mod1)
(apply #'idlwave-online-help mod1)
(error "Don't know which item to show help for")))))))
(defun idlwave-do-mouse-completion-help (ev)
@ -660,7 +649,7 @@ Those words in `idlwave-completion-help-links' have links. The
(props (list 'face 'idlwave-help-link))
(info idlwave-completion-help-info) ; global passed in
(what (nth 0 info)) ; what was completed, or a func
(class (nth 3 info)) ; any class
;; (class (nth 3 info)) ; any class
word beg end doit)
(goto-char (point-min))
(re-search-forward "possible completions are:" nil t)
@ -685,7 +674,7 @@ Those words in `idlwave-completion-help-links' have links. The
;; Arrange for this function to be called after completion
(add-hook 'idlwave-completion-setup-hook
'idlwave-highlight-linked-completions)
#'idlwave-highlight-linked-completions)
(defvar idlwave-help-return-frame nil
"The frame to return to from the help frame.")
@ -947,7 +936,7 @@ This function can be used as `idlwave-extra-help-function'."
(point)))
(defun idlwave-help-find-routine-definition (name type class keyword)
(defun idlwave-help-find-routine-definition (name type class _keyword)
"Find the definition of routine CLASS::NAME in current buffer.
Returns the point of match if successful, nil otherwise.
KEYWORD is ignored."
@ -967,7 +956,7 @@ KEYWORD is ignored."
(defvar idlwave-doclib-start)
(defvar idlwave-doclib-end)
(defun idlwave-help-find-in-doc-header (name type class keyword
(defun idlwave-help-find-in-doc-header (name _type class keyword
&optional exact)
"Find the requested help in the doc-header above point.
@ -1025,9 +1014,9 @@ If there is a match, we assume it is the keyword description."
":[ \t]*$\\)"))
;; Header start plus name
(header-re (concat "\\(" idlwave-doclib-start "\\).*\n"
"\\(^;+.*\n\\)*"
"\\(" name-re "\\)"))
;; (header-re (concat "\\(" idlwave-doclib-start "\\).*\n"
;; "\\(^;+.*\n\\)*"
;; "\\(" name-re "\\)"))
;; A keywords section
(kwds-re (concat ; forgiving
"^;+\\*?[ \t]*"
@ -1095,8 +1084,8 @@ When DING is non-nil, ring the bell as well."
(cons string idlwave-help-diagnostics))
(if ding (ding)))))
(defun idlwave-help-toggle-header-top-and-def (arg)
(interactive "P")
(defun idlwave-help-toggle-header-top-and-def (&optional _arg)
(interactive)
(let (pos)
(if idlwave-help-in-header
;; Header was the last thing displayed
@ -1119,8 +1108,8 @@ When DING is non-nil, ring the bell as well."
(goto-char pos)
(recenter 0)))))
(defun idlwave-help-find-first-header (arg)
(interactive "P")
(defun idlwave-help-find-first-header (&optional _arg)
(interactive)
(let (pos)
(save-excursion
(goto-char (point-min))
@ -1140,8 +1129,8 @@ When DING is non-nil, ring the bell as well."
(setq idlwave-help-in-header nil)
(idlwave-help-toggle-header-match-and-def arg 'top)))
(defun idlwave-help-toggle-header-match-and-def (arg &optional top)
(interactive "P")
(defun idlwave-help-toggle-header-match-and-def (&optional _arg top)
(interactive)
(let ((args idlwave-help-args)
pos)
(if idlwave-help-in-header
@ -1150,7 +1139,7 @@ When DING is non-nil, ring the bell as well."
(setq idlwave-help-in-header nil)
(setq pos idlwave-help-def-pos))
;; Try to display header
(setq pos (apply 'idlwave-help-find-in-doc-header
(setq pos (apply #'idlwave-help-find-in-doc-header
(if top
(list (car args) (nth 1 args) (nth 2 args) nil)
args)))
@ -1184,7 +1173,7 @@ Useful when source code is displayed as help. See the option
(with-no-warnings (font-lock-fontify-buffer))))))
(defun idlwave-help-error (name type class keyword)
(defun idlwave-help-error (name _type class keyword)
(error "Can't find help on %s%s %s"
(or (and (or class name) (idlwave-make-full-name class name))
"<unknown>")
@ -1272,11 +1261,11 @@ IDL assistant.")
(delete-process idlwave-help-assistant-socket))
(setq idlwave-help-assistant-process
(apply 'start-process
(apply #'start-process
"IDL_ASSISTANT_PROC" nil command "-server" extra-args))
(set-process-filter idlwave-help-assistant-process
(lambda (proc string)
(lambda (_proc string)
(setq port (string-to-number string))))
(unless (accept-process-output idlwave-help-assistant-process 15)
(error "Failed binding IDL_ASSISTANT socket"))

View file

@ -729,7 +729,7 @@ IDL is currently stopped.")
(defconst idlwave-shell-halt-messages-re
(mapconcat 'identity idlwave-shell-halt-messages "\\|")
(mapconcat #'identity idlwave-shell-halt-messages "\\|")
"The regular expression computed from `idlwave-shell-halt-messages'.")
(defconst idlwave-shell-trace-message-re
@ -934,8 +934,8 @@ IDL has currently stepped.")
"[ \t\n]*\\'"))
(when idlwave-shell-query-for-class
(add-to-list (make-local-variable 'idlwave-determine-class-special)
'idlwave-shell-get-object-class)
(add-hook 'idlwave-determine-class-functions
#'idlwave-shell-get-object-class nil t)
(setq idlwave-store-inquired-class t))
;; Make sure comint-last-input-end does not go to beginning of
@ -950,10 +950,10 @@ IDL has currently stepped.")
(setq idlwave-shell-default-directory default-directory)
(setq idlwave-shell-hide-output nil)
(add-hook 'kill-buffer-hook 'idlwave-shell-kill-shell-buffer-confirm
(add-hook 'kill-buffer-hook #'idlwave-shell-kill-shell-buffer-confirm
nil 'local)
(add-hook 'kill-buffer-hook 'idlwave-shell-delete-temp-files nil 'local)
(add-hook 'kill-emacs-hook 'idlwave-shell-delete-temp-files)
(add-hook 'kill-buffer-hook #'idlwave-shell-delete-temp-files nil 'local)
(add-hook 'kill-emacs-hook #'idlwave-shell-delete-temp-files)
;; Set the optional comint variables
(when idlwave-shell-comint-settings
@ -962,7 +962,7 @@ IDL has currently stepped.")
(set (make-local-variable (car entry)) (cdr entry)))))
(unless (memq 'comint-carriage-motion
(unless (memq #'comint-carriage-motion
(default-value 'comint-output-filter-functions))
;; Strip those pesky ctrl-m's.
(add-hook 'comint-output-filter-functions
@ -976,18 +976,21 @@ IDL has currently stepped.")
(while (search-forward "\r" pmark t)
(delete-region (point) (line-beginning-position)))))))
'append 'local)
(add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m nil 'local))
(add-hook 'comint-output-filter-functions #'comint-strip-ctrl-m nil 'local))
;; Python-mode, bundled with many Emacs installs, quite cavalierly
;; adds this function to the global default hook. It interferes
;; with overlay-arrows.
(remove-hook 'comint-output-filter-functions 'py-pdbtrack-track-stack-file)
;; FIXME: We should fix this interference rather than globally turn it off.
(when (fboundp 'py-pdbtrack-track-stack-file)
(remove-hook 'comint-output-filter-functions
#'py-pdbtrack-track-stack-file))
;; IDLWAVE syntax, and turn on abbreviations
(set (make-local-variable 'comment-start) ";")
(setq abbrev-mode t)
(add-hook 'post-command-hook 'idlwave-command-hook nil t)
(add-hook 'post-command-hook #'idlwave-command-hook nil t)
;; Read the command history?
(when (and idlwave-shell-save-command-history
@ -1045,7 +1048,7 @@ IDL has currently stepped.")
(setq idlwave-path-alist old-path-alist))))
(if (not (fboundp 'idl-shell))
(fset 'idl-shell 'idlwave-shell))
(defalias 'idl-shell #'idlwave-shell))
(defvar idlwave-shell-idl-wframe nil
"Frame for displaying the IDL shell window.")
@ -1120,7 +1123,7 @@ See also the variable `idlwave-shell-prompt-pattern'.
(and idlwave-shell-use-dedicated-frame
(setq idlwave-shell-idl-wframe (selected-frame)))
(add-hook 'idlwave-shell-sentinel-hook
'save-buffers-kill-emacs t))
#'save-buffers-kill-emacs t))
;; A non-nil arg means, we want a dedicated frame. This will last
;; for the current editing session.
@ -1130,7 +1133,7 @@ See also the variable `idlwave-shell-prompt-pattern'.
;; Check if the process still exists. If not, create it.
(unless (comint-check-proc (idlwave-shell-buffer))
(let* ((prg (or idlwave-shell-explicit-file-name "idl"))
(buf (apply 'make-comint
(buf (apply #'make-comint
idlwave-shell-process-name prg nil
(if (stringp idlwave-shell-command-line-options)
(idlwave-split-string
@ -1138,8 +1141,8 @@ See also the variable `idlwave-shell-prompt-pattern'.
idlwave-shell-command-line-options)))
(process (get-buffer-process buf)))
(setq idlwave-idlwave_routine_info-compiled nil)
(set-process-filter process 'idlwave-shell-filter)
(set-process-sentinel process 'idlwave-shell-sentinel)
(set-process-filter process #'idlwave-shell-filter)
(set-process-sentinel process #'idlwave-shell-sentinel)
(set-buffer buf)
(idlwave-shell-mode)))
(let ((window (idlwave-display-buffer (idlwave-shell-buffer) nil
@ -1315,10 +1318,7 @@ See also the variable `idlwave-shell-input-mode-spells'."
(setq idlwave-shell-char-mode-active 'exit))
((string-match (nth 1 idlwave-shell-input-mode-spells) string)
;; Set a timer which will soon start the character loop
(if (fboundp 'start-itimer)
(start-itimer "IDLWAVE Char Mode" 'idlwave-shell-char-mode-loop 0.5
nil nil t 'no-error)
(run-at-time 0.5 nil 'idlwave-shell-char-mode-loop 'no-error)))))
(run-at-time 0.5 nil #'idlwave-shell-char-mode-loop 'no-error))))
(defvar keyboard-quit)
(defun idlwave-shell-char-mode-loop (&optional no-error)
@ -1396,7 +1396,7 @@ Otherwise just move the line. Move down unless UP is non-nil."
(idlwave-shell-move-or-history nil arg))
(define-obsolete-function-alias 'idlwave-shell-comint-filter
'comint-output-filter "25.1")
#'comint-output-filter "25.1")
(defun idlwave-shell-is-running ()
"Return t if the shell process is running."
@ -1510,13 +1510,12 @@ and then calls `idlwave-shell-send-command' for any pending commands."
proc filtered))))))
;; Call the post-command hook
(if (listp idlwave-shell-post-command-hook)
(progn
;;(message "Calling list")
;;(prin1 idlwave-shell-post-command-hook)
(eval idlwave-shell-post-command-hook))
;;(message "Calling command function")
(funcall idlwave-shell-post-command-hook))
(if (functionp idlwave-shell-post-command-hook)
;;(message "Calling command function")
(funcall idlwave-shell-post-command-hook)
;;(message "Calling list")
;;(prin1 idlwave-shell-post-command-hook)
(eval idlwave-shell-post-command-hook t))
;; Reset to default state for next command.
;; Also we do not want to find this prompt again.
@ -1690,7 +1689,7 @@ the above."
(if bp
(let ((cmd (idlwave-shell-bp-get bp 'cmd)))
(if cmd ;; Execute any breakpoint command
(if (listp cmd) (eval cmd) (funcall cmd))))
(if (functionp cmd) (funcall cmd) (eval cmd t))))
;; A breakpoint that we did not know about - perhaps it was
;; set by the user... Let's update our list.
(idlwave-shell-bp-query)))
@ -1819,7 +1818,7 @@ The size is given by `idlwave-shell-graphics-window-size'."
(interactive "P")
(let ((n (if n (prefix-numeric-value n) 0)))
(idlwave-shell-send-command
(apply 'format "window,%d,xs=%d,ys=%d"
(apply #'format "window,%d,xs=%d,ys=%d"
n idlwave-shell-graphics-window-size)
nil (idlwave-shell-hide-p 'misc) nil t)))
@ -1891,7 +1890,7 @@ HEAP_GC, /VERBOSE"
(while (string-match "^PATH:[ \t]*<\\(.*\\)>[ \t]*\n" path-string start)
(push (match-string 1 path-string) dirs)
(setq start (match-end 0)))
(setq dirs (mapcar 'file-name-as-directory dirs))
(setq dirs (mapcar #'file-name-as-directory dirs))
(if (string-match "^SYSDIR:[ \t]*<\\(.*\\)>[ \t]*\n" path-string)
(setq sysdir (file-name-as-directory
(match-string 1 path-string))))
@ -1938,13 +1937,14 @@ HEAP_GC, /VERBOSE"
key (nth 4 specs)
keys (if (and (stringp key)
(not (string-match "\\` *\\'" key)))
(mapcar 'list
(mapcar #'list
(delete "" (idlwave-split-string key " +")))))
(setq name (idlwave-sintern-routine-or-method name class t)
class (idlwave-sintern-class class t)
file (if (equal file "") nil file)
keys (mapcar (lambda (x)
(list (idlwave-sintern-keyword (car x) t))) keys))
(list (idlwave-sintern-keyword (car x) t)))
keys))
;; In the following ignore routines already defined in buffers,
;; assuming that if the buffer stuff differs, it is a "new"
@ -2053,7 +2053,7 @@ Change the default directory for the process buffer to concur."
(match-string 1 idlwave-shell-command-output)))))
(defvar idlwave-sint-sysvars nil)
(idlwave-new-sintern-type 'execcomm)
(idlwave-new-sintern-type execcomm)
(defun idlwave-shell-complete (&optional arg)
"Do completion in the idlwave-shell buffer.
@ -2180,7 +2180,7 @@ overlays."
(defun idlwave-shell-parse-stack-and-display ()
(let* ((lines (delete "" (idlwave-split-string
idlwave-shell-command-output "^%")))
(stack (delq nil (mapcar 'idlwave-shell-parse-line lines)))
(stack (delq nil (mapcar #'idlwave-shell-parse-line lines)))
(nmax (1- (length stack)))
(nmin 0) message)
(cond
@ -2710,45 +2710,34 @@ Runs to the last statement and then steps 1 statement. Use the .out command."
(interactive "P")
(idlwave-shell-print arg 'help))
(defmacro idlwave-shell-mouse-examine (help &optional ev)
"Create a function for generic examination of expressions."
`(lambda (event)
"Expansion function for expression examination."
(interactive "e")
(let* ((drag-track (fboundp 'mouse-drag-track))
(transient-mark-mode t)
(tracker
;; Emacs 22 no longer completes the drag with
;; mouse-drag-region, without an additional
;; event. mouse-drag-track does so.
(if drag-track 'mouse-drag-track 'mouse-drag-region)))
(funcall tracker event)
(idlwave-shell-print (if (region-active-p) '(4) nil)
,help ,ev))))
(defun idlwave-shell--mouse-examine (event help &optional ev)
"Expansion function for expression examination."
(let* ((transient-mark-mode t))
(mouse-drag-track event)
(idlwave-shell-print (if (region-active-p) '(4) nil)
help ev)))
;; Begin terrible hack section -- XEmacs tests for button2 explicitly
;; on drag events, calling drag-n-drop code if detected. Ughhh...
(defun idlwave-default-mouse-track-event-is-with-button (_event _n)
(declare (obsolete nil "28.1"))
t)
(define-obsolete-function-alias
'idlwave-default-mouse-track-event-is-with-button #'always "28.1")
(define-obsolete-function-alias 'idlwave-xemacs-hack-mouse-track 'ignore "27.1")
(define-obsolete-function-alias 'idlwave-xemacs-hack-mouse-track
#'ignore "27.1")
;;; End terrible hack section
(defun idlwave-shell-mouse-print (event)
"Print value of variable at the mouse position, with `print'."
(interactive "e")
(funcall (idlwave-shell-mouse-examine nil) event))
(idlwave-shell--mouse-examine event nil))
(defun idlwave-shell-mouse-help (event)
"Print value of variable at the mouse position, with `help'."
(interactive "e")
(funcall (idlwave-shell-mouse-examine 'help) event))
(idlwave-shell--mouse-examine event 'help))
(defun idlwave-shell-examine-select (event)
"Pop-up a list to select from for examining the expression."
(interactive "e")
(funcall (idlwave-shell-mouse-examine nil event) event))
(idlwave-shell--mouse-examine event nil event))
(defmacro idlwave-shell-examine (help)
"Create a function for key-driven expression examination."
@ -2814,7 +2803,7 @@ from `idlwave-shell-examine-alist' via mini-buffer shortcut key."
(setq beg (region-beginning)
end (region-end)))
(t
(idlwave-with-special-syntax
(with-syntax-table idlwave-find-symbol-syntax-table
;; Move to beginning of current or previous expression
(if (looking-at "\\<\\|(")
;; At beginning of expression, don't move backwards unless
@ -2847,9 +2836,9 @@ from `idlwave-shell-examine-alist' via mini-buffer shortcut key."
(move-overlay idlwave-shell-expression-overlay beg end
(current-buffer))
(add-hook 'pre-command-hook
'idlwave-shell-delete-expression-overlay))
#'idlwave-shell-delete-expression-overlay))
(add-hook 'pre-command-hook
'idlwave-shell-delete-output-overlay)
#'idlwave-shell-delete-output-overlay)
;; Remove empty or comment-only lines
(while (string-match "\n[ \t]*\\(;.*\\)?\r*\n" expr)
@ -2881,7 +2870,7 @@ from `idlwave-shell-examine-alist' via mini-buffer shortcut key."
;; "Print")
(idlwave-popup-select
ev
(mapcar 'car idlwave-shell-examine-alist)
(mapcar #'car idlwave-shell-examine-alist)
"Examine with"))
idlwave-shell-examine-alist))))
(setq help (cdr help-cons))
@ -2916,9 +2905,8 @@ from `idlwave-shell-examine-alist' via mini-buffer shortcut key."
"Variable to hold the win/height pairs for all *Examine* windows.")
(defvar idlwave-shell-examine-map (make-sparse-keymap))
(define-key idlwave-shell-examine-map "q" 'idlwave-shell-examine-display-quit)
(define-key idlwave-shell-examine-map "c" 'idlwave-shell-examine-display-clear)
(define-key idlwave-shell-examine-map "q" #'idlwave-shell-examine-display-quit)
(define-key idlwave-shell-examine-map "c" #'idlwave-shell-examine-display-clear)
(defun idlwave-shell-check-compiled-and-display ()
"Check examine output for warning about undefined procedure/function."
@ -3347,9 +3335,10 @@ the breakpoint overlays."
count nil condition disabled))))))
(setq idlwave-shell-bp-alist (cdr idlwave-shell-bp-alist))
;; Update breakpoint data
(if (eq bp-re bp-re54)
(mapc 'idlwave-shell-update-bp old-bp-alist)
(mapc 'idlwave-shell-update-bp-command-only old-bp-alist))))
(mapc (if (eq bp-re bp-re54)
#'idlwave-shell-update-bp
#'idlwave-shell-update-bp-command-only)
old-bp-alist)))
;; Update the breakpoint overlays
(unless no-show (idlwave-shell-update-bp-overlays))
;; Return the new list
@ -3484,7 +3473,7 @@ The actual line number for a breakpoint in IDL may be different from
the line number used with the IDL breakpoint command.
Looks for a new breakpoint index number in the list. This is
considered the new breakpoint if the file name of frame matches."
(let ((obp-index (mapcar 'idlwave-shell-bp-get idlwave-shell-old-bp))
(let ((obp-index (mapcar #'idlwave-shell-bp-get idlwave-shell-old-bp))
(bpl idlwave-shell-bp-alist))
(while (and (member (idlwave-shell-bp-get (car bpl)) obp-index)
(setq bpl (cdr bpl))))
@ -3510,7 +3499,7 @@ considered the new breakpoint if the file name of frame matches."
(defvar idlwave-shell-debug-line-map (make-sparse-keymap))
(define-key idlwave-shell-debug-line-map [mouse-3]
'idlwave-shell-mouse-active-bp)
#'idlwave-shell-mouse-active-bp)
(defun idlwave-shell-update-bp-overlays ()
"Update the overlays which mark breakpoints in the source code.
@ -3532,7 +3521,7 @@ Existing overlays are recycled, in order to minimize consumption."
(setq ov-alist idlwave-shell-bp-overlays
idlwave-shell-bp-overlays
(if idlwave-shell-bp-glyph
(mapcar 'list (mapcar 'car idlwave-shell-bp-glyph))
(mapcar #'list (mapcar #'car idlwave-shell-bp-glyph))
(list (list 'bp))))
(while (setq bp (pop bp-list))
(save-excursion
@ -3568,7 +3557,7 @@ Existing overlays are recycled, in order to minimize consumption."
(if help-list
(concat
" - "
(mapconcat 'identity help-list ", ")))
(mapconcat #'identity help-list ", ")))
(if (and (not count) (not condition))
" (use mouse-3 for breakpoint actions)")))
(full-type (if disabled
@ -3962,73 +3951,73 @@ Otherwise, just expand the file name."
;;(define-key map "\M-?" 'comint-dynamic-list-completions)
;;(define-key map "\t" 'comint-dynamic-complete)
(define-key map "\C-w" 'comint-kill-region)
(define-key map "\t" 'idlwave-shell-complete)
(define-key map "\M-\t" 'idlwave-shell-complete)
(define-key map "\C-c\C-s" 'idlwave-shell)
(define-key map "\C-c?" 'idlwave-routine-info)
(define-key map "\C-g" 'idlwave-keyboard-quit)
(define-key map "\M-?" 'idlwave-context-help)
(define-key map "\C-w" #'comint-kill-region)
(define-key map "\t" #'idlwave-shell-complete)
(define-key map "\M-\t" #'idlwave-shell-complete)
(define-key map "\C-c\C-s" #'idlwave-shell)
(define-key map "\C-c?" #'idlwave-routine-info)
(define-key map "\C-g" #'idlwave-keyboard-quit)
(define-key map "\M-?" #'idlwave-context-help)
(define-key map [(control meta ?\?)]
'idlwave-help-assistant-help-with-topic)
(define-key map "\C-c\C-i" 'idlwave-update-routine-info)
(define-key map "\C-c\C-y" 'idlwave-shell-char-mode-loop)
(define-key map "\C-c\C-x" 'idlwave-shell-send-char)
(define-key map "\C-c=" 'idlwave-resolve)
(define-key map "\C-c\C-v" 'idlwave-find-module)
(define-key map "\C-c\C-k" 'idlwave-kill-autoloaded-buffers)
#'idlwave-help-assistant-help-with-topic)
(define-key map "\C-c\C-i" #'idlwave-update-routine-info)
(define-key map "\C-c\C-y" #'idlwave-shell-char-mode-loop)
(define-key map "\C-c\C-x" #'idlwave-shell-send-char)
(define-key map "\C-c=" #'idlwave-resolve)
(define-key map "\C-c\C-v" #'idlwave-find-module)
(define-key map "\C-c\C-k" #'idlwave-kill-autoloaded-buffers)
(define-key map idlwave-shell-prefix-key
'idlwave-shell-debug-map)
(define-key map [(up)] 'idlwave-shell-up-or-history)
(define-key map [(down)] 'idlwave-shell-down-or-history)
#'idlwave-shell-debug-map)
(define-key map [(up)] #'idlwave-shell-up-or-history)
(define-key map [(down)] #'idlwave-shell-down-or-history)
(define-key idlwave-shell-mode-map [(shift mouse-3)]
'idlwave-mouse-context-help)
#'idlwave-mouse-context-help)
map)
"Keymap for `idlwave-mode'.")
(defvar idlwave-shell-electric-debug-mode-map
(let ((map (make-sparse-keymap)))
;; A few extras in the electric debug map
(define-key map " " 'idlwave-shell-step)
(define-key map "+" 'idlwave-shell-stack-up)
(define-key map "=" 'idlwave-shell-stack-up)
(define-key map "-" 'idlwave-shell-stack-down)
(define-key map "_" 'idlwave-shell-stack-down)
(define-key map " " #'idlwave-shell-step)
(define-key map "+" #'idlwave-shell-stack-up)
(define-key map "=" #'idlwave-shell-stack-up)
(define-key map "-" #'idlwave-shell-stack-down)
(define-key map "_" #'idlwave-shell-stack-down)
(define-key map "e" (lambda () (interactive) (idlwave-shell-print '(16))))
(define-key map "q" 'idlwave-shell-retall)
(define-key map "q" #'idlwave-shell-retall)
(define-key map "t"
(lambda () (interactive) (idlwave-shell-send-command "help,/TRACE")))
(define-key map [(control ??)] 'idlwave-shell-electric-debug-help)
(define-key map [(control ??)] #'idlwave-shell-electric-debug-help)
(define-key map "x"
(lambda (arg) (interactive "P")
(idlwave-shell-print arg nil nil t)))
map))
(defvar idlwave-shell-mode-prefix-map (make-sparse-keymap))
(fset 'idlwave-shell-mode-prefix-map idlwave-shell-mode-prefix-map)
(defalias 'idlwave-shell-mode-prefix-map idlwave-shell-mode-prefix-map)
(defvar idlwave-mode-prefix-map (make-sparse-keymap))
(fset 'idlwave-mode-prefix-map idlwave-mode-prefix-map)
(defalias 'idlwave-mode-prefix-map idlwave-mode-prefix-map)
(defun idlwave-shell-define-key-both (key hook)
"Define a key in both the shell and buffer mode maps."
(define-key idlwave-mode-map key hook)
(define-key idlwave-shell-mode-map key hook))
(define-key idlwave-mode-map "\C-c\C-y" 'idlwave-shell-char-mode-loop)
(define-key idlwave-mode-map "\C-c\C-x" 'idlwave-shell-send-char)
(define-key idlwave-mode-map "\C-c\C-y" #'idlwave-shell-char-mode-loop)
(define-key idlwave-mode-map "\C-c\C-x" #'idlwave-shell-send-char)
;; The mouse bindings for PRINT and HELP
(idlwave-shell-define-key-both [(shift down-mouse-2)]
'idlwave-shell-mouse-print)
#'idlwave-shell-mouse-print)
(idlwave-shell-define-key-both [(control meta down-mouse-2)]
'idlwave-shell-mouse-help)
#'idlwave-shell-mouse-help)
(idlwave-shell-define-key-both [(control shift down-mouse-2)]
'idlwave-shell-examine-select)
#'idlwave-shell-examine-select)
;; We need to turn off the button release events.
(idlwave-shell-define-key-both [(shift mouse-2)] 'ignore)
(idlwave-shell-define-key-both [(shift control mouse-2)] 'ignore)
(idlwave-shell-define-key-both [(control meta mouse-2)] 'ignore)
(idlwave-shell-define-key-both [(shift mouse-2)] #'ignore)
(idlwave-shell-define-key-both [(shift control mouse-2)] #'ignore)
(idlwave-shell-define-key-both [(control meta mouse-2)] #'ignore)
;; The following set of bindings is used to bind the debugging keys.
@ -4109,8 +4098,8 @@ Otherwise, just expand the file name."
cmd))))
; Enter the prefix map in two places.
(fset 'idlwave-debug-map idlwave-mode-prefix-map)
(fset 'idlwave-shell-debug-map idlwave-shell-mode-prefix-map)
(defalias 'idlwave-debug-map idlwave-mode-prefix-map)
(defalias 'idlwave-shell-debug-map idlwave-shell-mode-prefix-map)
;; The Electric Debug Minor Mode --------------------------------------------
@ -4496,6 +4485,6 @@ static char * file[] = {
(idlwave-toolbar-toggle))
(if idlwave-shell-use-toolbar
(add-hook 'idlwave-shell-mode-hook 'idlwave-toolbar-add-everywhere))
(add-hook 'idlwave-shell-mode-hook #'idlwave-toolbar-add-everywhere))
;;; idlw-shell.el ends here

View file

@ -1,4 +1,4 @@
;;; idlw-toolbar.el --- a debugging toolbar for IDLWAVE
;;; idlw-toolbar.el --- a debugging toolbar for IDLWAVE -*- lexical-binding: t; -*-
;; Copyright (C) 1999-2021 Free Software Foundation, Inc.
@ -24,8 +24,8 @@
;;; Commentary:
;; This file implements a debugging toolbar for IDLWAVE. It requires
;; Emacs or XEmacs with toolbar and xpm support.
;; This file implements a debugging toolbar for IDLWAVE.
;; It requires toolbar and xpm support.
;; New versions of IDLWAVE, documentation, and more information
;; available from:
@ -35,22 +35,16 @@
;;; Code:
(defun idlwave-toolbar-make-button (image)
(if (featurep 'xemacs)
(toolbar-make-button-list image)
(list 'image :type 'xpm :data image)))
(list 'image :type 'xpm :data image))
(defvar idlwave-toolbar)
(defvar default-toolbar)
(defvar idlwave-toolbar-is-possible)
(if (not (or (and (featurep 'xemacs) ; This is XEmacs
(featurep 'xpm) ; need xpm
(featurep 'toolbar)) ; ... and the toolbar
(and (not (featurep 'xemacs)) ; This is Emacs
(boundp 'tool-bar-button-margin) ; need toolbar
(fboundp 'image-type-available-p) ; need image stuff
(image-type-available-p 'xpm)) ; need xpm
))
(if (not (and (boundp 'tool-bar-button-margin) ; need toolbar
(fboundp 'image-type-available-p) ; need image stuff
(image-type-available-p 'xpm)) ; need xpm
)
;; oops - cannot do the toolbar
(message "Sorry, IDLWAVE xpm toolbar cannot be used on this version of Emacs")
;; OK, we can define a toolbar
@ -873,23 +867,12 @@ static char * file[] = {
;; When the shell exits, arrange to remove the special toolbar everywhere.
(add-hook 'idlwave-shell-cleanup-hook
'idlwave-toolbar-remove-everywhere)
#'idlwave-toolbar-remove-everywhere)
);; End can define toolbar
(defun idlwave-toolbar-add ()
"Add the IDLWAVE toolbar if appropriate."
(if (and (featurep 'xemacs) ; This is a noop on Emacs
(boundp 'idlwave-toolbar-is-possible)
(derived-mode-p 'idlwave-mode 'idlwave-shell-mode))
(set-specifier default-toolbar (cons (current-buffer)
idlwave-toolbar))))
(define-obsolete-function-alias 'idlwave-toolbar-add #'ignore "28.1")
(defun idlwave-toolbar-remove ()
"Add the IDLWAVE toolbar if appropriate."
(if (and (featurep 'xemacs) ; This is a noop on Emacs
(boundp 'idlwave-toolbar-is-possible)
(derived-mode-p 'idlwave-mode 'idlwave-shell-mode))
(remove-specifier default-toolbar (current-buffer))))
(define-obsolete-function-alias 'idlwave-toolbar-remove #'ignore "28.1")
(defvar idlwave-shell-mode-map)
(defvar idlwave-mode-map)
@ -898,57 +881,40 @@ static char * file[] = {
"Add the toolbar in all appropriate buffers."
(when (boundp 'idlwave-toolbar-is-possible)
;; First make sure new buffers will get the toolbar
(add-hook 'idlwave-mode-hook 'idlwave-toolbar-add)
;; Then add it to all existing buffers
(if (featurep 'xemacs)
;; For XEmacs, map over all buffers to add toolbar
(save-excursion
(mapcar (lambda (buf)
(set-buffer buf)
(idlwave-toolbar-add))
(buffer-list)))
;; For Emacs, add the key definitions to the mode maps
(mapc (lambda (x)
(let* ((icon (aref x 0))
(func (aref x 1))
(show (aref x 2))
(help (aref x 3))
(key (vector 'tool-bar func))
(def (list 'menu-item
""
func
:image (symbol-value icon)
:visible show
:help help)))
(define-key idlwave-mode-map key def)
(define-key idlwave-shell-mode-map key def)))
(reverse idlwave-toolbar)))
;; For Emacs, add the key definitions to the mode maps
(mapc (lambda (x)
(let* ((icon (aref x 0))
(func (aref x 1))
(show (aref x 2))
(help (aref x 3))
(key (vector 'tool-bar func))
(def (list 'menu-item
""
func
:image (symbol-value icon)
:visible show
:help help)))
(define-key idlwave-mode-map key def)
(define-key idlwave-shell-mode-map key def)))
(reverse idlwave-toolbar))
(setq idlwave-toolbar-visible t)))
(defun idlwave-toolbar-remove-everywhere ()
"Remove the toolbar in all appropriate buffers."
;; First make sure new buffers won't get the toolbar
(when idlwave-toolbar-is-possible
(remove-hook 'idlwave-mode-hook 'idlwave-toolbar-add)
;; Then remove it in all existing buffers.
(if (featurep 'xemacs)
;; For XEmacs, map over all buffers to remove toolbar
(save-excursion
(mapcar (lambda (buf)
(set-buffer buf)
(idlwave-toolbar-remove))
(buffer-list)))
;; For Emacs, remove the key definitions from the mode maps
(mapc (lambda (x)
(let* (;;(icon (aref x 0))
(func (aref x 1))
;;(show (aref x 2))
;;(help (aref x 3))
(key (vector 'tool-bar func)))
(define-key idlwave-mode-map key nil)
(define-key idlwave-shell-mode-map key nil)))
idlwave-toolbar))
;; For Emacs, remove the key definitions from the mode maps
(mapc (lambda (x)
(let* (;;(icon (aref x 0))
(func (aref x 1))
;;(show (aref x 2))
;;(help (aref x 3))
(key (vector 'tool-bar func)))
(define-key idlwave-mode-map key nil)
(define-key idlwave-shell-mode-map key nil)))
idlwave-toolbar)
(setq idlwave-toolbar-visible nil)))
(defun idlwave-toolbar-toggle (&optional force-on)
@ -956,11 +922,8 @@ static char * file[] = {
(if idlwave-toolbar-visible
(or force-on (idlwave-toolbar-remove-everywhere))
(idlwave-toolbar-add-everywhere))
;; Now make sure this
(if (featurep 'xemacs)
nil ; no action necessary, toolbar gets updated automatically
;; On Emacs, redraw the frame to make sure the Toolbar is updated.
(redraw-frame)))
;; On Emacs, redraw the frame to make sure the Toolbar is updated.
(redraw-frame))
(provide 'idlw-toolbar)
(provide 'idlwave-toolbar)

File diff suppressed because it is too large Load diff