summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2025-07-26 23:45:01 +0800
committerJSDurand <mmemmew@gmail.com>2025-07-26 23:45:01 +0800
commitba7316ca594144e71d2f6b8326c604c51eafcd0f (patch)
treec6ca236f1cc29af2fb56cbe115882368991b584f
parent2bd09de5db48fd1cbcbffc77f5e1ab3c339dee61 (diff)
dudict: Add a special mode to be grouped in ibuffer
* durand-dict.el (dudict-mode, dudict-parse-agarathi) (dudict-parse-agarathi-panel): Add a special mode so that IBuffer can filter these buffers into the same group. * ibuffer.el (durand-bongo-set-filter): Add this filtering group.
-rw-r--r--durand-dict.el28
-rw-r--r--ibuffer.el1
2 files changed, 24 insertions, 5 deletions
diff --git a/durand-dict.el b/durand-dict.el
index c40ca68..09b6e06 100644
--- a/durand-dict.el
+++ b/durand-dict.el
@@ -32,6 +32,9 @@
;;; Code:
+(define-derived-mode dudict-mode org-mode "DUDICT"
+ "Major mode for viewing my custom dictionaries.")
+
(defun dudict-parse-agarathi (word)
"Request for the definition of Tamil WORD from the dictionary
website agarathi.
@@ -42,7 +45,7 @@ convert from some transliteration to the Tamil script."
(url-retrieve-synchronously
(concat "https://agarathi.com/word/" word)
t t 20))
- result)
+ result titles count)
(with-current-buffer buffer
(let* ((dom (libxml-parse-html-region
(point-min) (point-max)))
@@ -77,7 +80,7 @@ convert from some transliteration to the Tamil script."
(dudict-parse-agarathi-panel node)))
(cond
((string=
- (car result)
+ (cadr result)
"Sponsored Links")
nil)
(result))))
@@ -90,13 +93,20 @@ convert from some transliteration to the Tamil script."
(goto-char (point-min))
(mapc
(lambda (panel)
+ (setq titles (car panel))
+ (setq panel (cdr panel))
;; insert panel source
(insert "* " (car panel))
(setq panel (cdr panel))
+ (setq count 0)
(mapc
(lambda (def)
(newline)
- (insert "** def\n\n")
+ (insert
+ (format
+ "** %s\n\n"
+ (dom-text (nth count titles))))
+ (setq count (1+ count))
(mapc
(lambda (def)
(insert
@@ -113,7 +123,7 @@ convert from some transliteration to the Tamil script."
(newline 2))
result))
(switch-to-buffer buffer)
- (org-mode)
+ (dudict-mode)
(setq-local truncate-lines nil)
(goto-char (point-min))))
@@ -125,6 +135,12 @@ This is designed to be used by the function `dudict-parse-agarathi'."
(let* ((panel (car panel))
(panel-title
(dom-texts (car (dom-by-class panel "timeline-title"))))
+ (titles (delq
+ nil
+ (mapcar
+ (lambda (node)
+ (cond ((dom-attr node 'class) nil) (node)))
+ (dom-by-tag panel 'h3))))
(description
(delq
nil
@@ -137,7 +153,9 @@ This is designed to be used by the function `dudict-parse-agarathi'."
((stringp node) node)))
(dom-children desc)))
(dom-by-class panel "description")))))
- (cons panel-title (mapcar #'flatten-list description))))
+ (cons
+ titles
+ (cons panel-title (mapcar #'flatten-list description)))))
(dudict-parse-agarathi "கறுப்பு")
diff --git a/ibuffer.el b/ibuffer.el
index 2fdd3dc..c6c8989 100644
--- a/ibuffer.el
+++ b/ibuffer.el
@@ -443,6 +443,7 @@ value of `default-directory' in that buffer."
(cons "ELisp" '((mode . emacs-lisp-mode)))
(cons "EWW" '((mode . eww-mode)))
(cons "PDF" '((mode . pdf-view-mode)))
+ (cons "DICT" '((mode . dudict-mode)))
(cons "Eshell" '((mode . eshell-mode)))
(cons "Org" '((mode . org-mode)))
(cons "Roman" '((mode . novel-read-mode)))))