This repository has been archived by the owner on Nov 15, 2021. It is now read-only.
forked from mark-moseley/ruby-debug
-
Notifications
You must be signed in to change notification settings - Fork 80
/
rdebug-fns.el
111 lines (90 loc) · 3.79 KB
/
rdebug-fns.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
;;; rdebug-fns.el --- Ruby debugger miscellaneous functions
;; Copyright (C) 2008 Rocky Bernstein (rocky@gnu.org)
;; Copyright (C) 2008 Anders Lindgren
;; $Id: rdebug-frames.el 711 2008-02-20 07:09:17Z andersl $
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; See the manual and the file `rdebug.el' for more information.
;; This file contains code dealing with the frames secondary buffer.
;;; Code:
(require 'gud)
(require 'rdebug-vars)
(defun chomp(string &optional multiple)
"Remove trailing \n if it's there"
(if multiple
(progn
(while (and (> (length string) 0)
(eq (elt string (- (length string) 1)) ?\n))
(setq string (substring string 0 -1)))
string)
(if (> (length string) 0)
(let ((s string))
(if (string= "\n" (substring s -1))
(substring s 0 -1)
s))
"")))
(defun rdebug-dead-process-p ()
"Return true if the rdebug comint-process is dead or exited."
;; FIXME? Use a variable in gud-comint-buffer's status?
(or (not gud-comint-buffer)
(null (get-buffer-process gud-comint-buffer))
(not (member (process-status gud-comint-buffer) '(run open)))))
(defun rdebug-get-secondary-buffer-name (name)
"Get the rdebug NAME secondary buffer. If none found return nil."
(let ((target-name
(or (and gud-comint-buffer
(buffer-local-value 'gud-target-name
gud-comint-buffer))
gud-target-name)))
(cond ((and (string= "cmd" name) gud-comint-buffer)
(buffer-name gud-comint-buffer))
(t (format "*rdebug-%s-%s*" name target-name)))))
(defun rdebug-set-frame-top-arrow (buf)
"Set the fringe arrow in BUF to indicate the top frame."
(with-current-buffer buf
(setq fringe-indicator-alist
'((overlay-arrow . right-triangle)))))
(defun rdebug-set-frame-not-top-arrow (buf)
"Set the fringe arrow in BUF to indicate a frame other than the top frame."
(with-current-buffer buf
(setq fringe-indicator-alist
'((overlay-arrow . hollow-right-triangle)))))
(defun rdebug-set-frame-arrow (buf)
"Set the fringe arrow in buffer BUF."
(if (equal 0 rdebug-frames-current-frame-number)
(rdebug-set-frame-top-arrow buf)
(rdebug-set-frame-not-top-arrow buf)))
;; From Emacs 23
(unless (fboundp 'split-string-and-unquote)
(defun split-string-and-unquote (string &optional separator)
"Split the STRING into a list of strings.
It understands Emacs Lisp quoting within STRING, such that
(split-string-and-unquote (combine-and-quote-strings strs)) == strs
The SEPARATOR regexp defaults to \"\\s-+\"."
(let ((sep (or separator "\\s-+"))
(i (string-match "[\"]" string)))
(if (null i)
(split-string string sep t) ; no quoting: easy
(append (unless (eq i 0) (split-string (substring string 0 i) sep t))
(let ((rfs (read-from-string string i)))
(cons (car rfs)
(with-no-warnings
(split-string-and-unquote (substring string (cdr rfs))
sep))))))))
)
(provide 'rdebug-fns)
;;; Local variables:
;;; eval:(put 'rdebug-debug-enter 'lisp-indent-hook 1)
;;; End:
;;; rdebug-fns.el ends here