Function: gdb-load-history

gdb-load-history is a byte-compiled function defined in gdb-mi.el.gz.

Signature

(gdb-load-history)

Documentation

Load GDB history from a history file.

The name of the history file is given by environment variable GDBHISTFILE, falling back to ".gdb_history" and ".gdbinit".

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/gdb-mi.el.gz
(defun gdb-load-history ()
  "Load GDB history from a history file.
The name of the history file is given by environment variable GDBHISTFILE,
falling back to \".gdb_history\" and \".gdbinit\"."
  (when (ring-empty-p comint-input-ring) ; cf shell-mode
    (let ((hfile (expand-file-name (or (getenv "GDBHISTFILE")
				       (if (eq system-type 'ms-dos)
					   "_gdb_history"
					 ".gdb_history"))))
	  ;; gdb defaults to 256, but we'll default to comint-input-ring-size.
	  (hsize (getenv "HISTSIZE")))
      (dolist (file (append '("~/.gdbinit")
			    (unless (string-equal (expand-file-name ".")
                                                  (expand-file-name "~"))
			      '(".gdbinit"))))
	(if (file-readable-p (setq file (expand-file-name file)))
	    (with-temp-buffer
	      (insert-file-contents file)
	      ;; TODO? check for "set history save\\(  *on\\)?" and do
	      ;; not use history otherwise?
	      (while (re-search-forward
		      "^ *set history \\(filename\\|size\\)  *\\(.*\\)" nil t)
		(cond ((string-equal (match-string 1) "filename")
		       (setq hfile (expand-file-name
				    (match-string 2)
				    (file-name-directory file))))
		      ((string-equal (match-string 1) "size")
		       (setq hsize (match-string 2))))))))
      (and (stringp hsize)
	   (integerp (setq hsize (string-to-number hsize)))
	   (> hsize 0)
           (setq-local comint-input-ring-size hsize))
      (if (stringp hfile)
          (setq-local comint-input-ring-file-name hfile))
      (comint-read-input-ring t))))