Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

M-x relax reloads DB buffer if it's already open.

  • Loading branch information...
commit 318f4feffeba80b54c2a00c48580c62f5fafb806 1 parent 1d2a914
@technomancy authored
Showing with 16 additions and 6 deletions.
  1. +16 −6 relax.el
View
22 relax.el
@@ -106,6 +106,9 @@
(error "Not on a document line"))
(list (match-string 1 line) (match-string 2 line))))
+(defun relax-db-buffer-name (url)
+ (concat "*relax " url "*"))
+
;;; DB-level
(defvar relax-mode-hook nil)
@@ -141,15 +144,17 @@
(setq relax-host (url-host url)
relax-port (url-port url)
relax-db-path (url-filename url)))
- (if (boundp 'doc-list) ;; buffer has been initialized; needs refresh
- (relax-update-db)
- (url-retrieve (relax-url "_all_docs") 'relax-mode (list db-url))))
+ (if (not (get-buffer (relax-db-buffer-name db-url)))
+ (url-retrieve (relax-url "_all_docs") 'relax-mode (list db-url))
+ ;; buffer has been initialized; needs refresh
+ (switch-to-buffer (relax-db-buffer-name db-url))
+ (relax-update-db)))
(defun relax-mode (status database-url)
"Major mode for interacting with CouchDB databases."
(let ((json-buffer (current-buffer)))
(relax-trim-headers)
- (switch-to-buffer (concat "*relax " database-url "*"))
+ (switch-to-buffer (relax-db-buffer-name database-url))
(buffer-disable-undo)
(kill-all-local-variables)
@@ -203,8 +208,13 @@
(defun relax-kill-doc-from-db ()
"Issue a delete for the document under point."
(interactive)
- (apply 'relax-kill-document (append (relax-parse-db-line)
- '(relax-update-db))))
+ (let* ((line (relax-parse-db-line))
+ (id (car line))
+ (rev (cadr line)))
+ (lexical-let ((db-buffer (current-buffer)))
+ (relax-kill-document id rev (lambda (status)
+ (switch-to-buffer db-buffer)
+ (relax-update-db))))))
;;; Document-level
Please sign in to comment.
Something went wrong with that request. Please try again.