aboutsummaryrefslogtreecommitdiff
path: root/emacs/.emacs.d/lisp/my/my-mariadb.el
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/.emacs.d/lisp/my/my-mariadb.el')
-rw-r--r--emacs/.emacs.d/lisp/my/my-mariadb.el74
1 files changed, 71 insertions, 3 deletions
diff --git a/emacs/.emacs.d/lisp/my/my-mariadb.el b/emacs/.emacs.d/lisp/my/my-mariadb.el
index 52ca8bc..d6c2463 100644
--- a/emacs/.emacs.d/lisp/my/my-mariadb.el
+++ b/emacs/.emacs.d/lisp/my/my-mariadb.el
@@ -33,7 +33,9 @@
(interactive)
(if (equal (file-name-extension (buffer-file-name))
"test")
- (call-interactively 'project-compile)
+ (progn
+ (my-mtr-set-compile-command)
+ (call-interactively 'compile))
(sql-send-buffer)))
(defun my-gdb-maria ()
@@ -56,14 +58,14 @@
(when (and (buffer-live-p gud-comint-buffer)
(get-buffer-process gud-comint-buffer))
(my-gdb-quit))
- (sleep-for 1)
+ ;; (sleep-for 1)
(my-gdb
(format "rr replay %s -d %s"
(expand-file-name
(replace-regexp-in-string
"/src"
"/build/mysql-test/var/log/mysqld.1.1.rr/latest-trace"
- ;; "/build/mysql-test/var/log/mysqld.3.1.rr/latest-trace"
+ ;; "/build/mysql-test/var/log/mysqld.2.2.rr/latest-trace"
(project-root (project-current t))))
(expand-file-name "~/bin/gdb-mi.sh"))))
@@ -251,5 +253,71 @@ enum spider_malloc_id {
nil t)
(tempel-insert 'ps)))
+(defun my-mariadb-kb-url-p (url)
+ (string-match-p "https://mariadb.com/kb/en/\\([^/]+\\)/" url))
+
+(defun my-wiki-mariadb-extract-kb-source ()
+ "Extract the kb source from the current buffer.
+
+Used for wiki mode as a post-processor."
+ (let ((source
+ (dom-text
+ (dom-by-id
+ (libxml-parse-html-region (point-min) (point-max))
+ "answer_source"))))
+ (erase-buffer)
+ (insert source))
+ (goto-char (point-min))
+ (save-buffer)
+ )
+
+(defun my-mariadb-fetch-kb-source (url)
+ "Fetches the source to an maridb kb entry at URL.
+
+The source is saved in a .wiki file under the /tmp dir, and it
+switches to the buffer."
+ (interactive "sURL: ")
+ (let* ((term
+ (progn
+ (string-match "https://mariadb.com/kb/en/\\([^/]+\\)/" url)
+ (match-string 1 url)))
+ (source
+ (dom-text
+ (dom-by-id
+ (my-url-fetch-dom
+ (format "https://mariadb.com/kb/en/%s/+source/" term))
+ "answer_source")))
+ (file-name (format "/tmp/%s.wiki" term)))
+ (my-save-text-and-switch-to-buffer source file-name)))
+
+(defvar my-mtr-compilation-error-re
+ '(mtr "^mysqltest: At line \\([0-9]+\\)" nil 1))
+
+;; (defun my-mtr-find-test-file (test-name &optional dir)
+;; (unless dir (setq dir default-directory))
+;; ())
+
+(defun my-mtr-set-compile-command ()
+ (when (and buffer-file-name
+ (equal "test" (file-name-extension buffer-file-name)))
+ (when-let*
+ ((source-dir (expand-file-name (project-root (project-current))))
+ (build-dir (replace-regexp-in-string "/src/$" "/build/" source-dir))
+ (test-name
+ (progn
+ (when (string-match
+ "^.*/mysql-test/\\(.+?\\)/\\(t/\\)?\\([^/]+\\)\\.test$"
+ buffer-file-name)
+ (format "%s.%s"
+ (match-string 1 buffer-file-name)
+ (match-string 3 buffer-file-name))))))
+ (setq-local
+ compile-command
+ (format "%s %s %s %s"
+ "taskset -c 0-3"
+ (file-name-concat build-dir "mysql-test/mtr")
+ test-name
+ "--rr")))))
+
(provide 'my-mariadb)
;;; my-mariadb.el ends here