branch: externals/idlwave
commit eee38fb1188249cf6b1523931375d9e50989942a
Author: JD Smith <[email protected]>
Commit: JD Smith <[email protected]>
Moved shell completion functions to -complete
---
idlw-complete.el | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
idlw-shell.el | 66 ----------------------------------------------------
2 files changed, 70 insertions(+), 66 deletions(-)
diff --git a/idlw-complete.el b/idlw-complete.el
index 0e2ea19017..25a34f73ac 100644
--- a/idlw-complete.el
+++ b/idlw-complete.el
@@ -945,5 +945,75 @@ Restore the pre-completion window configuration if
possible."
(defvar idlwave-help-do-class-struct-tag nil)
+;;----------------------------------------------------
+;; Specialized completion in the shell
+
+(defun idlwave-shell-complete (&optional arg)
+ "Do completion in the idlwave-shell buffer.
+Calls `idlwave-shell-complete-filename' after some executive commands or
+in strings. Otherwise, calls `idlwave-complete' to complete modules and
+keywords."
+ (interactive "P")
+ (let (exec-cmd)
+ (cond
+ ((and
+ (setq exec-cmd (idlwave-shell-executive-command))
+ (cdr exec-cmd)
+ (member (upcase (cadr exec-cmd))
+ '(".R" ".RU" ".RUN" ".RN" ".RNE" ".RNEW"
+ ".COM" ".COMP" ".COMPI" ".COMPIL" ".COMPILE")))
+ ;; We are in a command line with an executive command
+ (idlwave-shell-complete-filename (not (idlwave-in-quote))))
+
+ ((car-safe exec-cmd)
+ (setq idlwave-completion-help-info
+ '(idlwave-shell-complete-execcomm-help))
+ (idlwave-complete-in-buffer 'execcomm 'execcomm
+ idlwave-executive-commands-alist nil
+ "Select an executive command"
+ "system variable"))
+
+ ((idlwave-shell-batch-command)
+ (idlwave-shell-complete-filename))
+
+ ((idlwave-shell-shell-command)
+ (idlwave-shell-complete-filename))
+
+ ((and (idlwave-shell-filename-string)
+ (save-excursion
+ (beginning-of-line)
+ (let ((case-fold-search t))
+ (not (looking-at ".*obj_new")))))
+ (idlwave-shell-complete-filename))
+
+ (t
+ ;; Default completion of modules and keywords
+ (idlwave-complete arg)))))
+
+;; Get rid of opaque dynamic variable passing of link?
+(defvar link) ;dynamic variable
+(defun idlwave-shell-complete-execcomm-help (mode word)
+ (let ((word (or (nth 1 idlwave-completion-help-info) word))
+ (entry (assoc-string word idlwave-executive-commands-alist t)))
+ (cond
+ ((eq mode 'test)
+ (and (stringp word) entry (cdr entry)))
+ ((eq mode 'set)
+ (if entry (setq link (cdr entry)))) ;; setting dynamic variable!!!
+ (t (error "This should not happen")))))
+
+(defun idlwave-shell-complete-filename (&optional nospace)
+ "Complete a file name at point if after a file name.
+We assume that we are after a file name when completing one of the
+args of an executive .run, .rnew or .compile."
+ ;; CWD might have changed, resync, to set default directory
+ (idlwave-shell-resync-dirs)
+ (let ((comint-file-name-chars
+ (if (and nospace (string-match "[ ]" idlwave-shell-file-name-chars))
+ (replace-match "" nil t idlwave-shell-file-name-chars)
+ idlwave-shell-file-name-chars)))
+ (comint-dynamic-complete-as-filename)))
+
+
(provide 'idlw-complete)
(provide 'idlwave-complete)
diff --git a/idlw-shell.el b/idlw-shell.el
index 28b20d08d4..94cff375aa 100644
--- a/idlw-shell.el
+++ b/idlw-shell.el
@@ -2259,72 +2259,6 @@ Change the default directory for the process buffer to
concur."
(add-hook 'idlwave-load-hook
(lambda () (idlwave-new-sintern-type 'execcomm)))
-(defun idlwave-shell-complete (&optional arg)
- "Do completion in the idlwave-shell buffer.
-Calls `idlwave-shell-complete-filename' after some executive commands or
-in strings. Otherwise, calls `idlwave-complete' to complete modules and
-keywords."
- (interactive "P")
- (let (exec-cmd)
- (cond
- ((and
- (setq exec-cmd (idlwave-shell-executive-command))
- (cdr exec-cmd)
- (member (upcase (cadr exec-cmd))
- '(".R" ".RU" ".RUN" ".RN" ".RNE" ".RNEW"
- ".COM" ".COMP" ".COMPI" ".COMPIL" ".COMPILE")))
- ;; We are in a command line with an executive command
- (idlwave-shell-complete-filename (not (idlwave-in-quote))))
-
- ((car-safe exec-cmd)
- (setq idlwave-completion-help-info
- '(idlwave-shell-complete-execcomm-help))
- (idlwave-complete-in-buffer 'execcomm 'execcomm
- idlwave-executive-commands-alist nil
- "Select an executive command"
- "system variable"))
-
- ((idlwave-shell-batch-command)
- (idlwave-shell-complete-filename))
-
- ((idlwave-shell-shell-command)
- (idlwave-shell-complete-filename))
-
- ((and (idlwave-shell-filename-string)
- (save-excursion
- (beginning-of-line)
- (let ((case-fold-search t))
- (not (looking-at ".*obj_new")))))
- (idlwave-shell-complete-filename))
-
- (t
- ;; Default completion of modules and keywords
- (idlwave-complete arg)))))
-
-;; Get rid of opaque dynamic variable passing of link?
-(defvar link) ;dynamic variable
-(defun idlwave-shell-complete-execcomm-help (mode word)
- (let ((word (or (nth 1 idlwave-completion-help-info) word))
- (entry (assoc-ignore-case word idlwave-executive-commands-alist)))
- (cond
- ((eq mode 'test)
- (and (stringp word) entry (cdr entry)))
- ((eq mode 'set)
- (if entry (setq link (cdr entry)))) ;; setting dynamic variable!!!
- (t (error "This should not happen")))))
-
-(defun idlwave-shell-complete-filename (&optional nospace)
- "Complete a file name at point if after a file name.
-We assume that we are after a file name when completing one of the
-args of an executive .run, .rnew or .compile."
- ;; CWD might have changed, resync, to set default directory
- (idlwave-shell-resync-dirs)
- (let ((comint-file-name-chars
- (if (and nospace (string-match "[ ]" idlwave-shell-file-name-chars))
- (replace-match "" nil t idlwave-shell-file-name-chars)
- idlwave-shell-file-name-chars)))
- (comint-dynamic-complete-as-filename)))
-
(defun idlwave-shell-executive-command ()
"Return the name of the current executive command, if any."
(save-excursion