"realgud-")
(require-relative-list '("init") "realgud:bashdb-")
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
(declare-function realgud-parse-command-arg 'realgud-core)
(declare-function realgud-query-cmdline 'realgud-core)
(declare-function realgud-suggest-invocation 'realgud-core)
((member arg '("--library" "-l"))
(setq arg (pop args))
(nconc debugger-args
- (list arg (expand-file-name (pop args)))))
+ (list arg (realgud:expand-file-name-if-exists
+ (pop args)))))
;; Other options with arguments.
((string-match "^-" arg)
(setq pair (realgud-parse-command-arg
(nconc debugger-args (car pair))
(setq args (cadr pair)))
;; Anything else must be the script to debug.
- (t (setq script-name (expand-file-name arg))
+ (t (setq script-name (realgud:expand-file-name-if-exists arg))
(setq script-args (cons script-name (cdr args))))
)))
(list interpreter-args debugger-args script-args annotate-p))))
"../../common/lang")
"realgud-")
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
(declare-function realgud-lang-mode? 'realgud-lang)
(declare-function realgud-parse-command-arg 'realgud-core)
(declare-function realgud-query-cmdline 'realgud-core)
(defun realgud:gdb-parse-cmd-args (orig-args)
"Parse command line ARGS for the annotate level and name of script to debug.
-ARGS should contain a tokenized list of the command line to run.
+ORIG_ARGS should contain a tokenized list of the command line to run.
We return the a list containing
-- the name of the debugger given (e.g. gdb) and its arguments - a list of strings
-- the script name and its arguments - list of strings
-- whether the annotate or emacs option was given ('-A', '--annotate' or '--emacs) - a boolean
+* the name of the debugger given (e.g. gdb) and its arguments - a list of strings
+* nil (a placehoder in other routines of this ilk for a debugger
+* the script name and its arguments - list of strings
+* whether the annotate or emacs option was given ('-A', '--annotate' or '--emacs) - a boolean
For example for the following input
(map 'list 'symbol-name
- '(gdb --tty /dev/pts/1 --emacs ./gcd.py a b))
+ '(gdb --tty /dev/pts/1 -cd ~ --emacs ./gcd.py a b))
we might return:
- ((gdb --tty /dev/pts/1 --emacs) (./gcd.py a b) 't)
+ ((\"gdb\" \"--tty\" \"/dev/pts/1\" \"-cd\" \"home/rocky\' \"--emacs\") nil \"(/tmp/gcd.py a b\") 't\")
-NOTE: the above should have each item listed in quotes.
+Note that path elements have been expanded via `expand-file-name'.
"
;; Parse the following kind of pattern:
(annotate-p nil))
(if (not (and args))
- ;; Got nothing: return '(nil nil nil)
- (list debugger-args script-args annotate-p)
+ ;; Got nothing: return '(nil nil nil nil)
+ (list debugger-args nil script-args annotate-p)
;; else
(progn
((string-match "^--annotate=[0-9]" arg)
(nconc debugger-args (list (pop args) (pop args)) )
(setq annotate-p t))
+ ;; path-argument ooptions
+ ((member arg '("-cd" ))
+ (setq arg (pop args))
+ (nconc debugger-args
+ (list arg (realgud:expand-file-name-if-exists
+ (pop args)))))
;; Options with arguments.
((string-match "^-" arg)
(setq pair (realgud-parse-command-arg
(t (setq script-name arg)
(setq script-args args))
)))
- (list debugger-args script-args annotate-p)))))
+ (list debugger-args nil script-args annotate-p)))))
(defvar realgud:gdb-command-name)
(defun realgud:gdb-suggest-invocation (debugger-name)
:type 'string
:group 'realgud:gdb)
-(declare-function gdb-track-mode (bool))
+(declare-function realgud:gdb-track-mode 'realgud:gdb-track-mode)
(declare-function realgud-command 'realgud:gdb-core)
(declare-function realgud:gdb-parse-cmd-args 'realgud:gdb-core)
(declare-function realgud:gdb-query-cmdline 'realgud:gdb-core)
-(declare-function realgud-run-process 'realgud-core)
+(declare-function realgud:run-process 'realgud-core)
;; -------------------------------------------------------------------
;; The end.
;;
+(require 'list-utils)
;;;###autoload
-(defun realgud:gdb (&optional opt-command-line no-reset)
+(defun realgud:gdb (&optional opt-cmd-line no-reset)
"Invoke the gdb debugger and start the Emacs user interface.
-OPT-COMMAND-LINE is treated like a shell string; arguments are
+OPT-CMD-LINE is treated like a shell string; arguments are
tokenized by `split-string-and-unquote'.
Normally, command buffers are reused when the same debugger is
"
(interactive)
- (let* ((cmd-str (or opt-command-line (realgud:gdb-query-cmdline "gdb")))
+ (let* ((cmd-str (or opt-cmd-line (realgud:gdb-query-cmdline "gdb")))
(cmd-args (split-string-and-unquote cmd-str))
(parsed-args (realgud:gdb-parse-cmd-args cmd-args))
- (script-args (cdr cmd-args))
- (script-name (expand-file-name (car script-args)))
- (cmd-buf (realgud-run-process realgud:gdb-command-name (car script-args) cmd-args
- 'realgud:gdb-track-mode nil))
+ (script-args (caddr parsed-args))
+ (script-name (car script-args))
+ (parsed-cmd-args
+ (remove-if 'nil (list-utils-flatten parsed-args)))
+ (cmd-buf (realgud:run-process realgud:gdb-command-name
+ script-name parsed-cmd-args
+ 'realgud:gdb-track-mode-hook nil))
)
(if cmd-buf
(with-current-buffer cmd-buf
)
)
)
-
- ;; ;; Parse the command line and pick out the script name and whether
- ;; ;; --annotate has been set.
-
- ;; (condition-case nil
- ;; (setq cmd-buf
- ;; (apply 'realgud-exec-shell "gdb" (car script-args)
- ;; (car cmd-args) nil
- ;; (cons script-name (cddr cmd-args))))
- ;; (error nil))
- ;; ;; FIXME: Is there probably is a way to remove the
- ;; ;; below test and combine in condition-case?
- ;; (let ((process (get-buffer-process cmd-buf)))
- ;; (if (and process (eq 'run (process-status process)))
- ;; (progn
- ;; (switch-to-buffer cmd-buf)
- ;; (realgud:gdb-track-mode 't)
- ;; (realgud-cmdbuf-info-cmd-args= cmd-args)
- ;; )
- ;; (message "Error running gdb command"))
- ;; )
- )
+ )
(provide-me "realgud-")
+
+;; Local Variables:
+;; byte-compile-warnings: (not cl-functions)
+;; End:
(require-relative-list '("../../common/track" "../../common/core") "realgud-")
(require-relative-list '("init") "realgud:kshdb-")
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+
;; FIXME: I think the following could be generalized and moved to
;; realgud-... probably via a macro.
(defvar kshdb-minibuffer-history nil
'kshdb-minibuffer-history
opt-debugger))
+;;; FIXME: DRY this with other *-parse-cmd-args routines
(defun kshdb-parse-cmd-args (orig-args)
"Parse command line ARGS for the annotate level and name of script to debug.
(nconc debugger-args (car pair))
(setq args (cadr pair)))
;; Anything else must be the script to debug.
- (t (setq script-name arg)
- (setq script-args args))
+ (t (setq script-name (realgud:expand-file-name-if-exists arg))
+ (setq script-args (cons script-name (cdr args))))
)))
(list interpreter-args debugger-args script-args annotate-p))))
(eval-when-compile (require 'cl))
(require 'load-relative)
-(require-relative-list '("../../common/track" "../../common/core") "realgud-")
+(require-relative-list '("../../common/track" "../../common/core")
+ "realgud-")
+(require-relative-list '("../../common/buffer/command")
+ "realgud-buffer-")
(require-relative-list '("init") "realgud:remake-")
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+(declare-function realgud-cmdbuf-command-string
+ 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-debugger-name
+ 'realgud-buffer-command)
;; FIXME: I think the following could be generalized and moved to
;; realgud-... probably via a macro.
(defvar remake-minibuffer-history nil
((member arg '("--file" "--makefile" "-f"))
(setq remake-args (nconc remake-args (list arg)))
- (setq makefile-name (pop args))
+ (setq makefile-name (realgud:expand-file-name-if-exists
+ (pop args)))
(setq remake-args (nconc remake-args
(list (format "%s" makefile-name)))))
(declare-function remake-query-cmdline 'realgud:remake-core)
(declare-function remake-parse-cmd-args 'realgud:remake-core)
-(declare-function realgud:run-process 'realgud:run)
+(declare-function realgud:run-debugger 'realgud:run)
;; -------------------------------------------------------------------
;; User definable variables
:group 'remake)
;;;###autoload
-(defun realgud:remake-fn (&optional opt-cmd-line no-reset)
+(defun realgud:remake (&optional opt-cmd-line no-reset)
"See `realgud:remake' for details"
-
- (let* ((cmd-str (or opt-cmd-line (remake-query-cmdline "remake")))
- (cmd-args (split-string-and-unquote cmd-str))
- (parsed-args (remake-parse-cmd-args cmd-args))
- (remake-program (car parsed-args))
- (makefile-name (or (cadr parsed-args) "Makefile"))
- (makefile-args (caddr parsed-args))
- (cmd-buf))
- (realgud:run-process "remake" makefile-name
- (cons remake-program makefile-args)
- 'remake-track-mode no-reset)
-
- ;; ;; Parse the command line and pick out the script name and whether
- ;; ;; --annotate has been set.
-
- ;; (condition-case nil
- ;; (setq cmd-buf
- ;; (apply 'realgud-exec-shell "remake" makefile-name
- ;; remake-program no-reset makefile-args))
- ;; (error nil))
- ;; ;; FIXME: Is there probably is a way to remove the
- ;; ;; below test and combine in condition-case?
- ;; (let ((process (get-buffer-process cmd-buf)))
- ;; (if (and process (eq 'run (process-status process)))
- ;; (progn
- ;; (switch-to-buffer cmd-buf)
- ;; (remake-track-mode 't)
- ;; (realgud-cmdbuf-info-cmd-args= cmd-args)
- ;; )
- ;; (message "Error running remake command"))
- ;; )
- )
+ (interactive)
+ (realgud:run-debugger "remake"
+ 'remake-query-cmdline
+ 'remake-parse-cmd-args
+ 'remake-track-mode-hook
+ opt-cmd-line no-reset)
)
(defalias 'remake 'realgud:remake)
((string-match "^--annotate=[0-9]" arg)
(nconc debugger-args (list (pop args)) )
(setq annotate-p t))
+ ;; path-argument options
+ ((member arg '("--include" "-I" "--require" "-I"))
+ (setq arg (pop args))
+ (nconc debugger-args
+ (list arg (realgud:expand-file-name-if-exists
+ (pop args)))))
;; Options with arguments.
((string-match "^-" arg)
(setq pair (realgud-parse-command-arg
--- /dev/null
+#!/usr/bin/env bash
+# Greatest Common Divisor in POSIX shell using Euclid's algorithm. On
+# return, variable gcd_value is set and is the gcd of parameters $1
+# and $2. The GCD of a negative number is the same as the GCD of its
+# absolute value, since a negative number is -1 times its positive
+# value. Negative numbers are set when there is an error; -1 is set
+# when the wrong number of parameters are given.
+gcd() {
+ typeset -i a=$1
+ typeset -i b=$2
+ if (( a > b )) ; then
+ a=$b
+ b=$1
+ fi
+ if (( a == 1 || (b-a) == 0)) ; then
+ gcd_value=$a
+ return 0
+ fi
+ typeset -i c
+ ((c=b-a))
+ gcd $c $a
+}
+
+gcd $1 $2
+echo $gcd_value
(require 'test-simple)
(load-file "../realgud/debugger/bashdb/bashdb.el")
+(load-file "../realgud/common/core.el")
+
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
(eval-when-compile (defvar test:run-process-save))
(format "%s %s %s %S" debugger-name script-filename cmd-args
track-mode-func))
(assert-equal "bashdb" debugger-name "debugger name gets passed")
- (let ((expanded-name (expand-file-name "./gcd.sh")))
+ (let ((expanded-name
+ (realgud:expand-file-name-if-exists "./gcd.sh")))
(assert-equal expanded-name script-filename "file name check")
(assert-equal (list "-l" (expand-file-name ".") expanded-name "3" "5")
(cdr cmd-args) "command args listified")
))
(note "bashdb-parse-cmd-args")
-(assert-equal (list nil '("bashdb") (list (expand-file-name "foo")) nil)
+(assert-equal (list nil '("bashdb")
+ (list (realgud:expand-file-name-if-exists "foo")) nil)
(bashdb-parse-cmd-args '("bashdb" "foo")))
-(assert-equal (list nil '("bashdb") (list (expand-file-name "program.sh") "foo") nil)
+(assert-equal (list nil '("bashdb")
+ (list (realgud:expand-file-name-if-exists "program.sh")
+ "foo") nil)
(bashdb-parse-cmd-args
'("bashdb" "program.sh" "foo")))
(require 'test-simple)
(load-file "../realgud/debugger/gub/core.el")
+(declare-function __FILE__ 'require-relative)
(declare-function gub-parse-cmd-args 'realgud-gub-core)
(test-simple-start)
(require 'test-simple)
(load-file "../realgud/debugger/remake/core.el")
+(declare-function __FILE__ 'require-relative)
+(declare-function remake-parse-cmd-args 'realgud-remake-core)
+(declare-function remake-suggest-Makefile 'realgud-remake-core)
+(declare-function remake-suggest-file-priority 'realgud-remake-core)
+
(test-simple-start)
-(assert-equal '("remake" "Makefile" ("-X" "-f" "Makefile"))
+(assert-equal (list "remake" (expand-file-name "Makefile")
+ (list "-X" "-f" (expand-file-name "Makefile")))
(remake-parse-cmd-args
- '("remake" "-X" "-f" "Makefile")) "remake-parse-cmd-args")
+ '("remake" "-X" "-f" "Makefile"))
+ "remake-parse-cmd-args")
(assert-equal "Makefile" (remake-suggest-Makefile) "remake-suggest-Makefile")