aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbru <bru@texto-plano.xyz>2023-07-10 17:07:50 -0300
committerbru <bru@texto-plano.xyz>2023-07-10 17:07:50 -0300
commit6c36357f24d1aeb537bfa2add1555e27c8fc7700 (patch)
treef9a059af9f8ad7476931a1a3b6ecbe8e3d3663f3
parent4187b2f4eafd342e683fc727885d33527ee01d61 (diff)
downloadbbj-6c36357f24d1aeb537bfa2add1555e27c8fc7700.tar.gz
Funcionalidad de borrar mensajesHEADmaster
-rw-r--r--clients/emacs/bbj.el29
1 files changed, 26 insertions, 3 deletions
diff --git a/clients/emacs/bbj.el b/clients/emacs/bbj.el
index fe9ab7e..8b45461 100644
--- a/clients/emacs/bbj.el
+++ b/clients/emacs/bbj.el
@@ -74,6 +74,7 @@ obnoxious things for the sake of education ;)")
(local-set-key (kbd "C-h SPC") 'bbj-pop-help)
(local-set-key (kbd "?") 'bbj-pop-help)
(local-set-key (kbd "e") 'bbj-edit-post)
+ (local-set-key (kbd "d") 'bbj-delete-post)
(local-set-key (kbd "C-c C-c") 'bbj-aux)
(local-set-key (kbd "r") 'bbj-quote-current-post))
@@ -109,7 +110,7 @@ obnoxious things for the sake of education ;)")
;; cuando lo único que tenía que hacer era redifinirla
;; para mi propio favor.
;; Lección aprendida. Aguante Emacs Lisp.
-(defun url-http-create-request ()
+(defun bbj-url-http-create-request ()
(let* ((extra-headers)
(request nil)
(no-cache (cdr-safe (assoc "Pragma" url-http-extra-headers)))
@@ -234,8 +235,11 @@ or can be ommitted to send no data."
(url-request-method "POST")
(url-request-data
(when alist (json-encode-alist alist)))
- (response (url-retrieve-synchronously
- (format "http://%s:%s/api/%s" bbj-host bbj-port endpoint) t)))
+ (response
+ (cl-letf (((symbol-function 'url-http-create-request)
+ #'bbj-url-http-create-request))
+ (url-retrieve-synchronously
+ (format "http://%s:%s/api/%s" bbj-host bbj-port endpoint) t))))
(when bbj-debug
(switch-to-buffer response))
@@ -825,6 +829,25 @@ Eso es todo por ahora.
(insert body)
(goto-char (point-min))))
+(defun bbj-delete-post ()
+ "Ask confirmation to delete the thread/post pointed by mark."
+ (interactive)
+ (let* ((data (bbj-post-prop 'data))
+ (is-thread (or (eq bbj-buffer-type 'index)
+ (= (alist-get 'post_id data) 0))))
+ (when (y-or-n-p (format "¿Seguro que quieres borrar permanentemente el %s?"
+ (if is-thread
+ "hilo entero" "post")))
+ (bbj-request 'delete_post
+ 'thread_id (alist-get 'thread_id data)
+ 'post_id (or (alist-get 'post_id data) 0)))
+ (if is-thread
+ (progn
+ (message "hilo borrado")
+ (quit-window)
+ (bbj-browse-index))
+ (message "post borrado")
+ (bbj-refresh))))
(defun bbj-browse-index ()
(interactive)
Un proyecto texto-plano.xyz