Skip to content

Commit db7b5c0

Browse files
committed
Better completion at point and don't compile on byte compile
1 parent 42d5c09 commit db7b5c0

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

gdb-mi.el

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@
3434

3535
(eval-and-compile
3636
(unless (bound-and-true-p module-file-suffix)
37-
(error "Dynamic modules are NOT supported in your build of Emacs"))
37+
(error "Dynamic modules are NOT supported in your build of Emacs")))
3838

39-
(let* ((default-directory (file-name-directory (or byte-compile-current-file load-file-name default-directory)))
40-
(required-module (concat "gdb-module" module-file-suffix))
41-
(path-to-module (concat default-directory required-module)))
39+
(let* ((default-directory (file-name-directory (or load-file-name default-directory)))
40+
(required-module (concat "gdb-module" module-file-suffix))
41+
(path-to-module (concat default-directory required-module)))
4242

43-
(if (file-exists-p required-module)
44-
(require 'gdb-module path-to-module)
43+
(if (file-exists-p required-module)
44+
(require 'gdb-module path-to-module)
4545

46-
(message "Compiling GDB dynamic module...")
47-
(with-current-buffer (compile (concat "make -k " required-module))
48-
(add-hook 'compilation-finish-functions (lambda (_buffer _status) (require 'gdb-module path-to-module))
49-
nil t)))))
46+
(message "Compiling GDB dynamic module...")
47+
(with-current-buffer (compile (concat "make -k " required-module))
48+
(add-hook 'compilation-finish-functions
49+
(lambda (_buffer _status) (require 'gdb-module path-to-module)) nil t))))
5050

5151
(declare-function gdb--handle-mi-output "ext:gdb-module")
5252

@@ -1215,16 +1215,19 @@ stopped thread before running the command. If FORCE-STOPPED is
12151215
(gdb--command "-exec-continue" nil stopped-thread)))))
12161216

12171217
(defun gdb--comint-completion-at-point ()
1218-
(let* ((real-beg (comint-line-beginning-position)) (end (point-max))
1219-
(str (buffer-substring-no-properties real-beg end)))
1220-
(unless (= real-beg end)
1221-
(setq beg (string-match " [^ ]+" str)
1222-
beg (or (and beg (+ real-beg 1 beg)) real-beg))
1223-
(list beg end
1224-
(completion-table-dynamic (lambda (_)
1225-
(let ((raw-list (gdb--get-console-data (concat "complete " str))))
1226-
(cl-loop for item in raw-list
1227-
collect (substring item (- beg real-beg))))))))))
1218+
(let* ((beg (comint-line-beginning-position)) (end (point-max))
1219+
(str (buffer-substring-no-properties beg end))
1220+
(relevant-index (string-match "\\( [^ .*]+\\|\\(\\.\\|\\*\\)[^ .]*\\)$" str)))
1221+
(unless (= beg end)
1222+
(when relevant-index
1223+
(setq relevant-index (1+ relevant-index)
1224+
beg (+ beg relevant-index)))
1225+
1226+
(list beg end (completion-table-dynamic
1227+
(lambda (_)
1228+
(let ((raw-list (gdb--get-console-data (concat "complete " str))))
1229+
(cl-loop for item in raw-list
1230+
collect (substring item relevant-index)))))))))
12281231

12291232

12301233
;; ------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)