aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbru <bru@texto-plano.xyz>2023-04-30 18:18:20 -0300
committerbru <bru@texto-plano.xyz>2023-04-30 18:18:20 -0300
commit1df97e0bd68fd0ebcad39c1fb050e45fe708ef73 (patch)
treef878ae1ac386dd1caf4c70b4b138f514ee58a99e
parent2a66bf99c203fdc59e64903b7fcfcc0172ab2b0f (diff)
downloadbbj-1df97e0bd68fd0ebcad39c1fb050e45fe708ef73.tar.gz
Mejoras en el cliente de Emacs
- Evita advertencias al usar 'cl-lib y los nombres no deprecados - Muestra posts fijados al comienzo de la lista
-rw-r--r--clients/emacs/bbj.el35
1 files changed, 21 insertions, 14 deletions
diff --git a/clients/emacs/bbj.el b/clients/emacs/bbj.el
index 48e4832..0056c30 100644
--- a/clients/emacs/bbj.el
+++ b/clients/emacs/bbj.el
@@ -1,7 +1,7 @@
(require 'json)
(require 'url)
(require 'shr)
-(require 'cl)
+(require 'cl-lib)
(defvar bbj-host "127.0.0.1")
(defvar bbj-port 7099)
@@ -137,7 +137,7 @@ or can be ommitted to send no data."
(error
(user-error "Error de respuesta BBJ"))))
- (case (setq error (alist-get 'error json)
+ (cl-case (setq error (alist-get 'error json)
edesc (alist-get 'description error)
ecode (alist-get 'code error))
((0 1 2 3) (error edesc))
@@ -308,7 +308,7 @@ just hunts for a specific text property."
(defun bbj-point-to-post (dir &optional nocenter)
"Move the cursor from the head of one post to another, in (symbol) DIR"
- (let ((check (case dir
+ (let ((check (cl-case dir
(prev (bbj-head-pos t))
(next (save-excursion ;; or else point will stick
(while (eq 'head (get-char-property (point) 'type))
@@ -360,7 +360,7 @@ just hunts for a specific text property."
"Handles the RETURN key (and other similar binds) depending on
content type. Currently only opens threads."
(interactive)
- (case bbj-buffer-type
+ (cl-case bbj-buffer-type
(index
(bbj-enter-thread
(alist-get 'thread_id (bbj-post-prop 'data))))))
@@ -369,7 +369,7 @@ content type. Currently only opens threads."
(defun bbj-quote-current-post ()
"Pop a composer, and insert the post number at point as a quote."
(interactive)
- (case bbj-buffer-type
+ (cl-case bbj-buffer-type
(thread
(let ((id (alist-get 'post_id (bbj-post-prop 'data))))
(bbj-compose)
@@ -387,7 +387,7 @@ content type. Currently only opens threads."
reply to one. Pops a new window; window is killed and the message
is sent using C-c C-c."
(interactive)
- (let ((params (case bbj-buffer-type
+ (let ((params (cl-case bbj-buffer-type
(index
`("Escribiendo nuevo hilo (C-c C-c para enviar)"
(lambda ()
@@ -472,12 +472,12 @@ and renders the content in the current buffer."
(format-time-string "%H:%M %a %m/%d/%y" (seconds-to-time epoch)))
-(defun bbj-render-post (post)
+(defun bbj-render-post (post &optional pinned)
"Render an API post object into the current buffer."
(let* ((title (alist-get 'title post))
(post-id (alist-get 'post_id post))
(userdata (cdr (assoc-string (alist-get 'author post) bbj-*usermap*)))
- (indicator (format ">>%s " (or title post-id))))
+ (indicator (format ">>%s%s " (if pinned "[FIJADO]" "") (or title post-id))))
(insert (propertize indicator
'face 'font-lock-function-name-face
'type 'head 'data post))
@@ -499,8 +499,8 @@ and renders the content in the current buffer."
(insert (alist-get 'body post))
(fill-region p (point))))
(insert "\n")
- ;; (bbj-render-body (alist-get 'body post))
- (bbj-insert-sep)))
+ (bbj-insert-sep)
+ ))
(defun bbj-render-tag-span (dom)
@@ -668,7 +668,7 @@ Eso es todo por ahora.
(defun bbj-refresh ()
"Reload current buffer. Tries to keep point position in threads."
(interactive)
- (case bbj-buffer-type
+ (cl-case bbj-buffer-type
(index
(let ((point (point)))
(bbj-browse-index)
@@ -721,9 +721,16 @@ Eso es todo por ahora.
bbj-*usermap* (alist-get 'usermap response)
mode-line-process '(":~%e" bbj-user))
(bbj-insert-sep t)
- (loop for thread across (alist-get 'data response) do
+ (cl-loop for thread in
+ (seq-filter (lambda (s) (alist-get 'pinned s))
+ (alist-get 'data response)) do
+ (bbj-render-post thread t)
+ (cl-incf count))
+ (cl-loop for thread in
+ (seq-remove (lambda (s) (alist-get 'pinned s))
+ (alist-get 'data response)) do
(bbj-render-post thread)
- (incf count))
+ (cl-incf count))
(bbj-postprocess)
(setq header-line-format (format
"%d posts. g para refrescar. <C-h Espacio> para ayuda."
@@ -755,7 +762,7 @@ Eso es todo por ahora.
(bbj-descend response 'data 'title)))
(setq-local thread-id id)
(bbj-insert-sep t)
- (loop for message across (bbj-descend response 'data 'messages) do
+ (cl-loop for message across (bbj-descend response 'data 'messages) do
(bbj-render-post message))
(bbj-postprocess))
(switch-to-buffer buffer)
Un proyecto texto-plano.xyz