[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 924969d 095/215: ipdb: add tab completion
From: |
Rocky Bernstein |
Subject: |
[elpa] master 924969d 095/215: ipdb: add tab completion |
Date: |
Sat, 30 Jul 2016 14:48:56 +0000 (UTC) |
branch: master
commit 924969d35faeed6e809d55e3a2a005d14aa1db3d
Author: Sean Farley <address@hidden>
Commit: Sean Farley <address@hidden>
ipdb: add tab completion
---
realgud/debugger/ipdb/core.el | 65 +++++++++++++++++++++++++++++++++++++++++
realgud/debugger/ipdb/ipdb.el | 1 +
2 files changed, 66 insertions(+)
diff --git a/realgud/debugger/ipdb/core.el b/realgud/debugger/ipdb/core.el
index fa697f8..43a42c5 100644
--- a/realgud/debugger/ipdb/core.el
+++ b/realgud/debugger/ipdb/core.el
@@ -195,6 +195,71 @@ breakpoints, etc.)."
;; (setcdr (assq 'ipdb-debugger-support-minor-mode minor-mode-map-alist)
;; ipdb-debugger-support-minor-mode-map-when-deactive))
+(defun realgud:ipdb-backend-complete ()
+ "Send a command to the ipdb buffer and parse the output.
+
+The idea here is to rely on the
+`comint-redirect-send-command-to-process' function to send a
+python command that will return the completions for the given
+input. Specifically, here is the python code:
+
+>>> from IPython import get_ipython
+>>> comp = '''%s'''
+>>> ';'.join(get_ipython().complete(comp.split()[-1] if len(comp)else '',
comp)[1])
+
+This returns a list of strings that match the current word (hence
+why we need the `bounds-of-thing-at-point')."
+ (interactive)
+ (let ((buffer (current-buffer))
+ (cmdbuf (realgud-get-cmdbuf))
+ (process (get-buffer-process (current-buffer)))
+ (end-position (point))
+ (bounds (bounds-of-thing-at-point 'word))
+ )
+
+ ;; get the input string
+ (save-excursion
+ (comint-goto-process-mark)
+ (let* ((start-position (point))
+ (input-str (buffer-substring-no-properties start-position
+ end-position))
+ )
+ (when (not (= (length input-str) 0))
+ (let* ((python-str (concat
+ "from IPython import get_ipython; "
+ "comp = '''%s''';"
+ "';'.join(get_ipython()"
+ ".complete(comp.split()[-1] if len(comp)"
+ "else '', comp)[1])"))
+ (command-str (format python-str input-str))
+ (output-str (with-temp-buffer
+ (let ((tmpbuf (current-buffer)))
+ (comint-redirect-send-command-to-process
+ command-str tmpbuf process nil t)
+ ;; Wait for the process to complete
+ (set-buffer (process-buffer process))
+ (while (null comint-redirect-completed)
+ (accept-process-output nil 0 5)) ;; wait 5ms
+ (set-buffer tmpbuf)
+ (buffer-substring (1+ (point-min))
+ (1- (1- (point-max)))))))
+ )
+
+ ;; we need to change the start position to that of the current word
+ ;; since python returns just the word (and not the whole line)
+ (setq start-position (car bounds))
+
+ (list start-position
+ end-position
+ (split-string output-str ";"))))))))
+
+(defun realgud:ipdb-completion-at-point ()
+ (let ((ipdb (realgud:ipdb-backend-complete)))
+ (when ipdb
+ (list (nth 0 ipdb)
+ (nth 1 ipdb)
+ (nth 2 ipdb)
+ :exclusive 'yes))))
(defun realgud:ipdb-customize ()
"Use `customize' to edit the settings of the `ipdb' debugger."
diff --git a/realgud/debugger/ipdb/ipdb.el b/realgud/debugger/ipdb/ipdb.el
index 29d0540..4f12301 100644
--- a/realgud/debugger/ipdb/ipdb.el
+++ b/realgud/debugger/ipdb/ipdb.el
@@ -46,6 +46,7 @@ This should be an executable on your path, or an absolute
file name."
(declare-function ipdb-track-mode 'realgud:ipdb-track)
(declare-function ipdb-query-cmdline 'realgud:ipdb-core)
(declare-function ipdb-parse-cmd-args 'realgud:ipdb-core)
+(declare-function realgud:ipdb-completion-at-point 'realgud:ipdb-core)
(declare-function realgud:run-debugger 'realgud:run)
;;;###autoload
- [elpa] master 26369c1 074/215: Typo, (continued)
- [elpa] master 26369c1 074/215: Typo, Rocky Bernstein, 2016/07/30
- [elpa] master 4a83877 064/215: perl5db alias messes up realgud-track-mode, so drop that name., Rocky Bernstein, 2016/07/30
- [elpa] master d3953ae 092/215: Fix bug in picking out short-key variable name introduced by recent changes, Rocky Bernstein, 2016/07/30
- [elpa] master 2facb99 075/215: init.el: break and clear command use %X rather than %l, Rocky Bernstein, 2016/07/30
- [elpa] master 7edc244 063/215: wrong args in jdb invocation; issue #51. Disable some jdb commands we, Rocky Bernstein, 2016/07/30
- [elpa] master ca52896 071/215: A workaround: reinitialize shell mode when going out of realgud-track-mode, Rocky Bernstein, 2016/07/30
- [elpa] master eee3112 089/215: track.el: Allow us to separate stem variable name to get debugger config from debugger name. This will make it easier, Rocky Bernstein, 2016/07/30
- [elpa] master 1eda9a1 076/215: Partially addresses #61. Handling multiple breakpoints on a line still, Rocky Bernstein, 2016/07/30
- [elpa] master a216bf0 084/215: Last commit set wrong variables, Rocky Bernstein, 2016/07/30
- [elpa] master 1420ff1 096/215: ipdb: add hook for completion to initialization, Rocky Bernstein, 2016/07/30
- [elpa] master 924969d 095/215: ipdb: add tab completion,
Rocky Bernstein <=
- [elpa] master 518dccd 070/215: Merge branch 'master' of github.com:rocky/emacs-dbgr, Rocky Bernstein, 2016/07/30
- [elpa] master 30398e1 099/215: ipdb: add test, Rocky Bernstein, 2016/07/30
- [elpa] master 6a5c71d 112/215: Merge pull request #80 from cpitclaudel/master, Rocky Bernstein, 2016/07/30
- [elpa] master 5bcb424 082/215: Add Kilian, Rocky Bernstein, 2016/07/30
- [elpa] master 75737a0 121/215: Merge pull request #90 from cpitclaudel/82-add-prefix-arg-to-c, Rocky Bernstein, 2016/07/30
- [elpa] master e8fc998 116/215: Merge pull request #85 from cpitclaudel/84-pdb-fixes, Rocky Bernstein, 2016/07/30
- [elpa] master 0cf9321 125/215: Small fixes in cmds.el, Rocky Bernstein, 2016/07/30
- [elpa] master 8c8f9f1 093/215: Not sure why this initialization was there, but it is syntactically, Rocky Bernstein, 2016/07/30
- [elpa] master 6a87f3c 097/215: ipdb: add tab completion to track-mode, Rocky Bernstein, 2016/07/30
- [elpa] master cfe2be3 107/215: Reinstate ipdb support, Rocky Bernstein, 2016/07/30