I am uploading a NMU to DELAYED/10 in order to fix this.
The debdiff is attached.
diff -Nru dictem-1.0.4/TODO dictem-1.0.4/TODO
--- dictem-1.0.4/TODO   2024-02-18 18:30:30.000000000 +0000
+++ dictem-1.0.4/TODO   2016-09-03 06:29:36.000000000 +0000
@@ -1 +1,6 @@
+- "er" dictionary + geek
+- antonym for "l". "n" and "p"?
+- keep p/n history in buffers with numbers.
+- does dictem-use-existing-buffer work properly?
+
 Do you have ideas, want new features, see bugs? Let me know ;-)
diff -Nru dictem-1.0.4/debian/changelog dictem-1.0.4/debian/changelog
--- dictem-1.0.4/debian/changelog       2024-02-18 18:30:30.000000000 +0000
+++ dictem-1.0.4/debian/changelog       2024-02-18 18:23:58.000000000 +0000
@@ -1,3 +1,12 @@
+dictem (1.0.4-4.2) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Convert to source format 3.0. Closes: #1043092
+  * d/copyright: Convert to machine-readable format.
+  * Remove trailing empty line from description.
+
+ -- Bastian Germann <b...@debian.org>  Sun, 18 Feb 2024 18:23:58 +0000
+
 dictem (1.0.4-4.1) unstable; urgency=medium
 
   * Non maintainer upload by the Reproducible Builds team.
diff -Nru dictem-1.0.4/debian/control dictem-1.0.4/debian/control
--- dictem-1.0.4/debian/control 2024-02-18 18:30:30.000000000 +0000
+++ dictem-1.0.4/debian/control 2024-02-18 18:23:58.000000000 +0000
@@ -21,5 +21,3 @@
  It uses autocompletion that is used for selecting dictionary and 
  search strategy.  Moreover, DictEm provides several hooks which 
  may be used for buffer postprocessing.
- .
-
diff -Nru dictem-1.0.4/debian/copyright dictem-1.0.4/debian/copyright
--- dictem-1.0.4/debian/copyright       2024-02-18 18:30:30.000000000 +0000
+++ dictem-1.0.4/debian/copyright       2024-02-18 18:23:58.000000000 +0000
@@ -1,27 +1,29 @@
-This package was debianized by Zhenja Kaluta <y.kali...@gmail.com> on
-Fri, 24 Sep 2004 12:38:21 +0300.
-
-Downloaded From: http://www.mova.org/~cheusov/pub/dictem/
-
-Upstream Author: Aleksey Cheusov <v...@gmx.net>
-
-Copyright (c) 2003, 2004 Aleksey Cheusov <v...@gmx.net>
-
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Comment:
+ This package was debianized by Zhenja Kaluta <y.kali...@gmail.com> on
+ Fri, 24 Sep 2004 12:38:21 +0300.
+Source:
+ http://www.mova.org/~cheusov/pub/dictem/
+Upstream-Contact:
+ Aleksey Cheusov <v...@gmx.net>
+
+Files: *
+Copyright: (c) 2003, 2004 Aleksey Cheusov <v...@gmx.net>
+License: GPL-2+
    DictEm is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-
+ .
    DictEm is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-
+ .
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
    USA
-
-On Debian systems, the complete text of the GNU General
-Public License can be found in `/usr/share/common-licenses/GPL-2'.
-
+Comment:
+ On Debian systems, the complete text of the GNU General
+ Public License can be found in `/usr/share/common-licenses/GPL-2'.
diff -Nru dictem-1.0.4/debian/patches/debian.patch 
dictem-1.0.4/debian/patches/debian.patch
--- dictem-1.0.4/debian/patches/debian.patch    1970-01-01 00:00:00.000000000 
+0000
+++ dictem-1.0.4/debian/patches/debian.patch    2024-02-18 18:23:58.000000000 
+0000
@@ -0,0 +1,462 @@
+--- dictem-1.0.4.orig/TODO
++++ dictem-1.0.4/TODO
+@@ -1,6 +1 @@
+-- "er" dictionary + geek
+-- antonym for "l". "n" and "p"?
+-- keep p/n history in buffers with numbers.
+-- does dictem-use-existing-buffer work properly?
+-
+ Do you have ideas, want new features, see bugs? Let me know ;-)
+--- dictem-1.0.4.orig/dictem.el
++++ dictem-1.0.4/dictem.el
+@@ -476,62 +476,82 @@ This variable is local to buffer")
+ (defun dictem-local-dict-basic-option (host port option-mime)
+   (let ((server-host (if host host (dictem-get-server))))
+     (append
+-     (list "-P" "-")
++     (list "-P" "-" 
++         "--client" (dictem-client-text))
+      (if server-host
+        (list "-h" server-host "-p" (dictem-get-port port)))
+      (if option-mime '("-M"))
+      dictem-client-prog-args-list
+      )))
+ 
+-(defun dictem-call-process (buffer host port args)
+-  (let (coding-system
+-      coding-system-for-read
+-      coding-system-for-write)
+-    (if (and (functionp 'coding-system-list)
+-           (member 'utf-8 (coding-system-list)))
+-      (setq coding-system 'utf-8))
+-    (setq coding-system-for-read coding-system)
+-    (setq coding-system-for-write coding-system)
+-    (apply 'call-process
+-         `(,dictem-client-prog
+-           nil
+-           ,(dictem-get-buffer buffer)
+-           nil
+-           ,@(dictem-local-dict-basic-option host port nil)
+-           ,@args
+-           ))))
+-
+ (defun dictem-call-process-SHOW-SERVER (buffer host port)
+-  (dictem-call-process buffer host port '("-I")))
++  (apply 'call-process
++       `(,dictem-client-prog
++         nil
++         ,(dictem-get-buffer buffer)
++         nil
++         ,@(dictem-local-dict-basic-option host port nil)
++         "-I")))
+ 
+ (defun dictem-call-process-SHOW-INFO (buffer db host port)
+-  (dictem-call-process buffer host port (list "-i" db)))
++  (apply 'call-process
++       `(,dictem-client-prog
++         nil
++         ,(dictem-get-buffer buffer)
++         nil
++         ,@(dictem-local-dict-basic-option host port nil)
++         "-i" ,db)))
+ 
+ (defun dictem-call-process-SHOW-STRAT (buffer host port)
+-  (dictem-call-process buffer host port '("-S")))
++  (apply 'call-process
++       `(,dictem-client-prog
++         nil
++         ,(dictem-get-buffer buffer)
++         nil
++         ,@(dictem-local-dict-basic-option host port nil)
++         "-S")))
+ 
+ (defun dictem-call-process-SHOW-DB (buffer host port)
+-  (dictem-call-process buffer host port '("-D")))
++  (apply 'call-process
++       `(,dictem-client-prog
++         nil
++         ,(dictem-get-buffer buffer)
++         nil
++         ,@(dictem-local-dict-basic-option host port nil)
++         "-D")))
+ 
+ (defun dictem-call-process-MATCH (buffer db query strat host port)
+-  (dictem-call-process
+-   buffer host port
+-   (list "-m"
+-       "-d" (if db db "*")
+-       "-s" (if strat strat ".")
+-       query)))
++  (apply 'call-process
++       `(,dictem-client-prog
++         nil
++         ,(dictem-get-buffer buffer)
++         nil
++         ,@(dictem-local-dict-basic-option host port nil)
++         "-m"
++         "-d" ,(if db db "*")
++         "-s" ,(if strat strat ".")
++         ,query)))
+ 
+ (defun dictem-call-process-DEFINE (buffer db query host port)
+-  (dictem-call-process
+-   buffer host port
+-   (list "-d" (if db db "*") query)))
++  (apply 'call-process
++       `(,dictem-client-prog
++         nil
++         ,(dictem-get-buffer buffer)
++         nil
++         ,@(dictem-local-dict-basic-option host port dictem-option-mime)
++         "-d" ,(if db db "*")
++         ,query)))
+ 
+ (defun dictem-call-process-SEARCH (buffer db query strat host port)
+-  (dictem-call-process
+-   buffer host port
+-   (list "-d" (if db db "*")
+-       "-s" (if strat strat ".")
+-       query)))
++  (apply 'call-process
++       `(,dictem-client-prog
++         nil
++         ,(dictem-get-buffer buffer)
++         nil
++         ,@(dictem-local-dict-basic-option host port dictem-option-mime)
++         "-d" ,(if db db "*")
++         "-s" ,(if strat strat ".")
++         ,query)))
+ 
+ ;;;;;        GET Functions         ;;;;;
+ 
+@@ -1136,58 +1156,59 @@ to enter a database name."
+        )
+       ex_status)
+ 
+-    (let ((selected-window (frame-selected-window))
++    (let ((coding-system nil))
++      (if (and (functionp 'coding-system-list)
++             (member 'utf-8 (coding-system-list)))
++        (setq coding-system 'utf-8))
++      (let ((selected-window (frame-selected-window))
++          (coding-system-for-read coding-system)
++          (coding-system-for-write coding-system)
+           ; here we remember values of variables local to buffer
+-        (server           dictem-server)
+-        (port             dictem-port)
+-        (dbs              dictem-database-alist)
+-        (strats           dictem-strategy-alist)
+-        (user-dbs         dictem-user-databases-alist)
+-        (user-only        dictem-use-user-databases-only)
+-        (use-existing-buf dictem-use-existing-buffer)
++          (server           dictem-server)
++          (port             dictem-port)
++          (dbs              dictem-database-alist)
++          (strats           dictem-strategy-alist)
++          (user-dbs         dictem-user-databases-alist)
++          (user-only        dictem-use-user-databases-only)
++          (use-existing-buf dictem-use-existing-buffer)
+ ;         (option-mime      dictem-option-mime)
+-        (dict-buf         nil)
+-        )
+-      (cond
+-       ((eq dictem-use-existing-buffer 'always)
+-      (dictem-ensure-buffer))
+-       ((eq dictem-use-existing-buffer t)
+-      (dictem-ensure-buffer))
+-       (t
+-      (dictem))
+-       0)
+-      (setq dict-buf (buffer-name))
++          (dict-buf         nil)
++          )
++      (if dictem-use-existing-buffer
++          (dictem-ensure-buffer)
++        (dictem))
++      (setq dict-buf (buffer-name))
+ ;     (set-buffer-file-coding-system coding-system)
+-      (make-local-variable 'dictem-default-strategy)
+-      (make-local-variable 'dictem-default-database)
+-      (make-local-variable 'case-replace)
+-      (make-local-variable 'case-fold-search)
++      (make-local-variable 'dictem-default-strategy)
++      (make-local-variable 'dictem-default-database)
++      (make-local-variable 'case-replace)
++      (make-local-variable 'case-fold-search)
+ 
+       ; the following lines are to inherit values local to buffer
+-      (set (make-local-variable 'dictem-server) server)
+-      (set (make-local-variable 'dictem-port)   port)
+-      (set (make-local-variable 'dictem-database-alist) dbs)
+-      (set (make-local-variable 'dictem-strategy-alist) strats)
+-      (set (make-local-variable 'dictem-user-databases-alist) user-dbs)
+-      (set (make-local-variable 'dictem-use-user-databases-only) user-only)
+-      (set (make-local-variable 'dictem-use-existing-buffer) use-existing-buf)
++      (set (make-local-variable 'dictem-server) server)
++      (set (make-local-variable 'dictem-port)   port)
++      (set (make-local-variable 'dictem-database-alist) dbs)
++      (set (make-local-variable 'dictem-strategy-alist) strats)
++      (set (make-local-variable 'dictem-user-databases-alist) user-dbs)
++      (set (make-local-variable 'dictem-use-user-databases-only) user-only)
++      (set (make-local-variable 'dictem-use-existing-buffer) use-existing-buf)
+ 
+ ;     (set (make-local-variable 'dictem-option-mime) option-mime)
+ 
+-      (set (make-local-variable 'dictem-hyperlinks-alist) nil)
++      (set (make-local-variable 'dictem-hyperlinks-alist) nil)
+ 
+       ;;;;;;;;;;;;;;
+-      (setq case-replace nil)
+-      (setq case-fold-search nil)
+-      (setq dictem-error-messages nil)
+-      (dictem-local-run-functions search-fun database query strategy)
+-      (switch-to-buffer dict-buf)
+-      (if (and (not (equal ex_status 0)) (= (point-min) (point-max)))
+-        (insert (dictem-generate-full-error-message ex_status)))
+-      (goto-char (point-min))
+-      (setq buffer-read-only t)
+-      ex_status
+-      )))
++      (setq case-replace nil)
++      (setq case-fold-search nil)
++      (setq dictem-error-messages nil)
++      (dictem-local-run-functions search-fun database query strategy)
++      (switch-to-buffer dict-buf)
++      (if (and (not (equal ex_status 0)) (= (point-min) (point-max)))
++          (insert (dictem-generate-full-error-message ex_status)))
++      (goto-char (point-min))
++      (setq buffer-read-only t)
++      ex_status
++      ))))
+ 
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ (defun dictem-next-section ()
+@@ -1709,70 +1730,55 @@ the function 'dictem-postprocess-definit
+                )))))
+     ))
+ 
+-(defun dictem-find-brackets (re-beg re-end)
+-  (let ((beg-beg (make-marker))
+-      (beg-end (make-marker))
+-      (end-beg (make-marker))
+-      (end-end (make-marker)))
+-    (if (search-forward-regexp re-beg nil t)
+-      (progn
+-        (set-marker beg-beg (match-beginning 0))
+-        (set-marker beg-end (match-end 0))
+-        (if (search-forward-regexp re-end nil t)
+-            (progn
+-              (set-marker end-beg (match-beginning 0))
+-              (set-marker end-end (match-end 0))
+-              (list beg-beg beg-end end-beg end-end))
+-          nil))
+-      nil)))
+-
+-(defun dictem-postprocess-definition-hyperlinks-cyrlybr1 ()
+-  (save-excursion
+-    (goto-char (point-min))
+-    (let ((regexp) (pos) (beg1) (beg2) (beg3) (end) (word))
+-
+-      (while (setq pos (dictem-find-brackets dictem-hyperlink-beginning
+-                                           dictem-hyperlink-end))
+-      (delete-region (nth 0 pos) (nth 1 pos))
+-      (delete-region (nth 2 pos) (nth 3 pos))
+-      (setq word (buffer-substring-no-properties (nth 1 pos) (nth 2 pos)))
+-      (dictem-create-link
+-       (nth 1 pos) (nth 2 pos)
+-       'dictem-reference-definition-face
+-       dictem-hyperlink-define-func
+-       (list (cons 'word (dictem-replace-spaces word))
+-             (cons 'dbname dictem-current-dbname))
+-       '(link t))))))
+-
+-(defun dictem-postprocess-definition-hyperlinks-curlybr2 ()
++(defun dictem-postprocess-definition-hyperlinks ()
+   (save-excursion
+     (goto-char (point-min))
+     (let ((regexp
+-         (concat dictem-hyperlink-beginning "\\([^{}|\n]+\\)|\\([^{}|\n]+\\)"
+-                 dictem-hyperlink-end)))
++         (concat dictem-hyperlink-beginning "\\([^{}|]+\\)" 
dictem-hyperlink-end
++                 "\\|"
++                 "^From [^\n]+\\[\\([^\n]+\\)\\]"
++                 "\\|"
++                 "\\(" dictem-hyperlink-beginning 
"\\([^{}|\n]+\\)|\\([^{}|\n]+\\)"
++                 dictem-hyperlink-end "\\)")))
+ 
+       (while (search-forward-regexp regexp nil t)
+-      (let* ((beg (match-beginning 5))
+-             (end (match-end 5))
+-             (match-beg (match-beginning 3))
+-             (repl-beg (match-beginning 4))
+-             (repl-end (match-end 4))
+-             (repl (buffer-substring-no-properties repl-beg repl-end))
+-             (word (buffer-substring-no-properties beg end)))
+-        (replace-match repl t t)
+-        (dictem-create-link
+-         match-beg (+ match-beg (length repl))
+-         'dictem-reference-definition-face
+-         dictem-hyperlink-define-func
+-         (list (cons 'word (dictem-replace-spaces word))
+-               (cons 'dbname dictem-current-dbname))
+-         '(link t)))))))
+-
+-(defun dictem-postprocess-definition-hyperlinks ()
+-  (dictem-postprocess-definition-hyperlinks-cyrlybr1)
+-  (dictem-postprocess-definition-hyperlinks-curlybr2)
+-;  (dictem-postprocess-definition-hyperlinks-curlybr2)
+-  )
++      (cond ((match-beginning 1)
++             (let* ((beg (match-beginning 1))
++                    (end (match-end 1))
++                    (match-beg (match-beginning 0))
++                    (word (buffer-substring-no-properties beg end)))
++               (replace-match word t t)
++               (dictem-create-link
++                match-beg (+ match-beg (length word))
++                'dictem-reference-definition-face
++                dictem-hyperlink-define-func
++                (list (cons 'word (dictem-replace-spaces word))
++                      (cons 'dbname dictem-current-dbname))
++                '(link t))
++               ))
++            ((match-beginning 2)
++             (if (null dictem-current-dbname)
++                 (setq dictem-current-dbname
++                       (dictem-replace-spaces
++                        (buffer-substring-no-properties (match-beginning 2)
++                                                        (match-end 2))))))
++            ((match-beginning 3)
++             (let* ((beg (match-beginning 5))
++                    (end (match-end 5))
++                    (match-beg (match-beginning 3))
++                    (repl-beg (match-beginning 4))
++                    (repl-end (match-end 4))
++                    (repl (buffer-substring-no-properties repl-beg repl-end))
++                    (word (buffer-substring-no-properties beg end)))
++               (replace-match repl t t)
++               (dictem-create-link
++                match-beg (+ match-beg (length repl))
++                'dictem-reference-definition-face
++                dictem-hyperlink-define-func
++                (list (cons 'word (dictem-replace-spaces word))
++                      (cons 'dbname dictem-current-dbname))
++                '(link t))))
++            )))))
+ 
+ (defun dictem-postprocess-match ()
+   (save-excursion
+@@ -1826,113 +1832,6 @@ the function 'dictem-postprocess-definit
+             (kill-line 1))
+           )))))
+ 
+-(defun dictem-add-text-face-properties (start end face-add-props
+-                                            &optional object)
+-  (let (face-props)
+-    (while (<= start end)
+-      (progn
+-      (setq face-props (get-text-property start 'face object))
+-      (if (facep face-props)
+-          (progn
+-            (setq face-props nil)
+-            (add-text-properties
+-             start (+ 1 start)
+-             (list 'face nil)
+-             object)))
+-      (add-text-properties
+-       start (+ 1 start)
+-       (list 'face (append face-props face-add-props))
+-       object)
+-      (setq start (+ start 1))))))
+-
+-(defun dictem-add-begendre-face-propertires (re-beg re-end face-properties)
+-  (let ((bold-beg-beg (make-marker))
+-      (bold-beg-end (make-marker))
+-      (bold-end-beg (make-marker))
+-      (bold-end-end (make-marker)))
+-    (while (search-forward-regexp re-beg nil t)
+-      (progn
+-      (set-marker bold-beg-beg (match-beginning 0))
+-      (set-marker bold-beg-end (match-end 0))
+-      (if (search-forward-regexp re-end nil t)
+-          (progn
+-            (set-marker bold-end-beg (match-beginning 0))
+-            (set-marker bold-end-end (match-end 0))
+-            (dictem-add-text-face-properties
+-             bold-beg-end (- bold-end-beg 1) face-properties)
+-            (delete-region bold-beg-beg bold-beg-end)
+-            (delete-region bold-end-beg bold-end-end)
+-            ))))))
+-
+-(defun dictem-postprocess-stardict-definition ()
+-  (interactive)
+-
+-  (goto-char (point-min))
+-  (dictem-add-begendre-face-propertires
+-   "<b>" "</b>" '(:weight bold))
+-
+-  (goto-char (point-min))
+-  (dictem-add-begendre-face-propertires
+-   "<k>" "</k>" '(:height 1.2 :foreground "white" :weight bold))
+-
+-  (goto-char (point-min))
+-  (dictem-add-begendre-face-propertires
+-   "<abr>" "</abr>" '(:weight bold :foreground "green"))
+-
+-  (goto-char (point-min))
+-  (dictem-add-begendre-face-propertires
+-   "<dtrn>" "</dtrn>" '())
+-
+-  (goto-char (point-min))
+-  (dictem-add-begendre-face-propertires
+-   "<c c=\"green\">" "</c>" '(:foreground "green"))
+-
+-  (goto-char (point-min))
+-  (dictem-add-begendre-face-propertires
+-   "<c c=\"brown\">" "</c>" '(:foreground "brown"))
+-
+-  (goto-char (point-min))
+-  (dictem-add-begendre-face-propertires
+-   "<c>" "</c>" '(:foreground "green"))
+-
+-  (goto-char (point-min))
+-  (dictem-add-begendre-face-propertires
+-   "<ex>" "</ex>" '(:foreground "BurlyWood"))
+-
+-  (goto-char (point-min))
+-  (dictem-add-begendre-face-propertires
+-   "<i>" "</i>" '(:slant "oblique"))
+-
+-  (goto-char (point-min))
+-  (dictem-add-begendre-face-propertires
+-   "<c c=\"blueviolet\">" "</c>" '(:foreground "lightblue"))
+-
+-  ; replaceing <tr> with [
+-  (goto-char (point-min))
+-  (while (search-forward-regexp "<tr>" nil t)
+-    (replace-match "[" t t))
+-
+-  ; replaceing </tr> with ]
+-  (goto-char (point-min))
+-  (while (search-forward-regexp "</tr>" nil t)
+-    (replace-match "]" t t))
+-
+-  ; replaceing <co> with (
+-  (goto-char (point-min))
+-  (while (search-forward-regexp "<co>" nil t)
+-    (replace-match "" t t))
+-
+-  ; replaceing </co> with (
+-  (goto-char (point-min))
+-  (while (search-forward-regexp "</co>" nil t)
+-    (replace-match "" t t))
+-
+-  (let ((dictem-hyperlink-beginning "<kref>")
+-      (dictem-hyperlink-end "</kref>"))
+-    (dictem-postprocess-definition-hyperlinks-cyrlybr1))
+-
+-  )
+-
+ ;;;;;       On-Click Functions     ;;;;;
+ (defun dictem-define-on-press ()
+   "Is called upon pressing Enter."
diff -Nru dictem-1.0.4/debian/patches/series dictem-1.0.4/debian/patches/series
--- dictem-1.0.4/debian/patches/series  1970-01-01 00:00:00.000000000 +0000
+++ dictem-1.0.4/debian/patches/series  2024-02-18 18:23:58.000000000 +0000
@@ -0,0 +1 @@
+debian.patch
diff -Nru dictem-1.0.4/debian/source/format dictem-1.0.4/debian/source/format
--- dictem-1.0.4/debian/source/format   2024-02-18 18:30:30.000000000 +0000
+++ dictem-1.0.4/debian/source/format   2024-02-18 18:23:58.000000000 +0000
@@ -1 +1 @@
-1.0
+3.0 (quilt)
diff -Nru dictem-1.0.4/dictem.el dictem-1.0.4/dictem.el
--- dictem-1.0.4/dictem.el      2024-02-18 18:30:30.000000000 +0000
+++ dictem-1.0.4/dictem.el      2016-09-03 06:29:36.000000000 +0000
@@ -476,82 +476,62 @@
 (defun dictem-local-dict-basic-option (host port option-mime)
   (let ((server-host (if host host (dictem-get-server))))
     (append
-     (list "-P" "-" 
-          "--client" (dictem-client-text))
+     (list "-P" "-")
      (if server-host
         (list "-h" server-host "-p" (dictem-get-port port)))
      (if option-mime '("-M"))
      dictem-client-prog-args-list
      )))
 
+(defun dictem-call-process (buffer host port args)
+  (let (coding-system
+       coding-system-for-read
+       coding-system-for-write)
+    (if (and (functionp 'coding-system-list)
+            (member 'utf-8 (coding-system-list)))
+       (setq coding-system 'utf-8))
+    (setq coding-system-for-read coding-system)
+    (setq coding-system-for-write coding-system)
+    (apply 'call-process
+          `(,dictem-client-prog
+            nil
+            ,(dictem-get-buffer buffer)
+            nil
+            ,@(dictem-local-dict-basic-option host port nil)
+            ,@args
+            ))))
+
 (defun dictem-call-process-SHOW-SERVER (buffer host port)
-  (apply 'call-process
-        `(,dictem-client-prog
-          nil
-          ,(dictem-get-buffer buffer)
-          nil
-          ,@(dictem-local-dict-basic-option host port nil)
-          "-I")))
+  (dictem-call-process buffer host port '("-I")))
 
 (defun dictem-call-process-SHOW-INFO (buffer db host port)
-  (apply 'call-process
-        `(,dictem-client-prog
-          nil
-          ,(dictem-get-buffer buffer)
-          nil
-          ,@(dictem-local-dict-basic-option host port nil)
-          "-i" ,db)))
+  (dictem-call-process buffer host port (list "-i" db)))
 
 (defun dictem-call-process-SHOW-STRAT (buffer host port)
-  (apply 'call-process
-        `(,dictem-client-prog
-          nil
-          ,(dictem-get-buffer buffer)
-          nil
-          ,@(dictem-local-dict-basic-option host port nil)
-          "-S")))
+  (dictem-call-process buffer host port '("-S")))
 
 (defun dictem-call-process-SHOW-DB (buffer host port)
-  (apply 'call-process
-        `(,dictem-client-prog
-          nil
-          ,(dictem-get-buffer buffer)
-          nil
-          ,@(dictem-local-dict-basic-option host port nil)
-          "-D")))
+  (dictem-call-process buffer host port '("-D")))
 
 (defun dictem-call-process-MATCH (buffer db query strat host port)
-  (apply 'call-process
-        `(,dictem-client-prog
-          nil
-          ,(dictem-get-buffer buffer)
-          nil
-          ,@(dictem-local-dict-basic-option host port nil)
-          "-m"
-          "-d" ,(if db db "*")
-          "-s" ,(if strat strat ".")
-          ,query)))
+  (dictem-call-process
+   buffer host port
+   (list "-m"
+        "-d" (if db db "*")
+        "-s" (if strat strat ".")
+        query)))
 
 (defun dictem-call-process-DEFINE (buffer db query host port)
-  (apply 'call-process
-        `(,dictem-client-prog
-          nil
-          ,(dictem-get-buffer buffer)
-          nil
-          ,@(dictem-local-dict-basic-option host port dictem-option-mime)
-          "-d" ,(if db db "*")
-          ,query)))
+  (dictem-call-process
+   buffer host port
+   (list "-d" (if db db "*") query)))
 
 (defun dictem-call-process-SEARCH (buffer db query strat host port)
-  (apply 'call-process
-        `(,dictem-client-prog
-          nil
-          ,(dictem-get-buffer buffer)
-          nil
-          ,@(dictem-local-dict-basic-option host port dictem-option-mime)
-          "-d" ,(if db db "*")
-          "-s" ,(if strat strat ".")
-          ,query)))
+  (dictem-call-process
+   buffer host port
+   (list "-d" (if db db "*")
+        "-s" (if strat strat ".")
+        query)))
 
 ;;;;;        GET Functions         ;;;;;
 
@@ -1156,59 +1136,58 @@
        )
       ex_status)
 
-    (let ((coding-system nil))
-      (if (and (functionp 'coding-system-list)
-              (member 'utf-8 (coding-system-list)))
-         (setq coding-system 'utf-8))
-      (let ((selected-window (frame-selected-window))
-           (coding-system-for-read coding-system)
-           (coding-system-for-write coding-system)
+    (let ((selected-window (frame-selected-window))
            ; here we remember values of variables local to buffer
-           (server           dictem-server)
-           (port             dictem-port)
-           (dbs              dictem-database-alist)
-           (strats           dictem-strategy-alist)
-           (user-dbs         dictem-user-databases-alist)
-           (user-only        dictem-use-user-databases-only)
-           (use-existing-buf dictem-use-existing-buffer)
+         (server           dictem-server)
+         (port             dictem-port)
+         (dbs              dictem-database-alist)
+         (strats           dictem-strategy-alist)
+         (user-dbs         dictem-user-databases-alist)
+         (user-only        dictem-use-user-databases-only)
+         (use-existing-buf dictem-use-existing-buffer)
 ;          (option-mime      dictem-option-mime)
-           (dict-buf         nil)
-           )
-       (if dictem-use-existing-buffer
-           (dictem-ensure-buffer)
-         (dictem))
-       (setq dict-buf (buffer-name))
+         (dict-buf         nil)
+         )
+      (cond
+       ((eq dictem-use-existing-buffer 'always)
+       (dictem-ensure-buffer))
+       ((eq dictem-use-existing-buffer t)
+       (dictem-ensure-buffer))
+       (t
+       (dictem))
+       0)
+      (setq dict-buf (buffer-name))
 ;      (set-buffer-file-coding-system coding-system)
-       (make-local-variable 'dictem-default-strategy)
-       (make-local-variable 'dictem-default-database)
-       (make-local-variable 'case-replace)
-       (make-local-variable 'case-fold-search)
+      (make-local-variable 'dictem-default-strategy)
+      (make-local-variable 'dictem-default-database)
+      (make-local-variable 'case-replace)
+      (make-local-variable 'case-fold-search)
 
        ; the following lines are to inherit values local to buffer
-       (set (make-local-variable 'dictem-server) server)
-       (set (make-local-variable 'dictem-port)   port)
-       (set (make-local-variable 'dictem-database-alist) dbs)
-       (set (make-local-variable 'dictem-strategy-alist) strats)
-       (set (make-local-variable 'dictem-user-databases-alist) user-dbs)
-       (set (make-local-variable 'dictem-use-user-databases-only) user-only)
-       (set (make-local-variable 'dictem-use-existing-buffer) use-existing-buf)
+      (set (make-local-variable 'dictem-server) server)
+      (set (make-local-variable 'dictem-port)   port)
+      (set (make-local-variable 'dictem-database-alist) dbs)
+      (set (make-local-variable 'dictem-strategy-alist) strats)
+      (set (make-local-variable 'dictem-user-databases-alist) user-dbs)
+      (set (make-local-variable 'dictem-use-user-databases-only) user-only)
+      (set (make-local-variable 'dictem-use-existing-buffer) use-existing-buf)
 
 ;      (set (make-local-variable 'dictem-option-mime) option-mime)
 
-       (set (make-local-variable 'dictem-hyperlinks-alist) nil)
+      (set (make-local-variable 'dictem-hyperlinks-alist) nil)
 
        ;;;;;;;;;;;;;;
-       (setq case-replace nil)
-       (setq case-fold-search nil)
-       (setq dictem-error-messages nil)
-       (dictem-local-run-functions search-fun database query strategy)
-       (switch-to-buffer dict-buf)
-       (if (and (not (equal ex_status 0)) (= (point-min) (point-max)))
-           (insert (dictem-generate-full-error-message ex_status)))
-       (goto-char (point-min))
-       (setq buffer-read-only t)
-       ex_status
-       ))))
+      (setq case-replace nil)
+      (setq case-fold-search nil)
+      (setq dictem-error-messages nil)
+      (dictem-local-run-functions search-fun database query strategy)
+      (switch-to-buffer dict-buf)
+      (if (and (not (equal ex_status 0)) (= (point-min) (point-max)))
+         (insert (dictem-generate-full-error-message ex_status)))
+      (goto-char (point-min))
+      (setq buffer-read-only t)
+      ex_status
+      )))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (defun dictem-next-section ()
@@ -1730,55 +1709,70 @@
                 )))))
     ))
 
-(defun dictem-postprocess-definition-hyperlinks ()
+(defun dictem-find-brackets (re-beg re-end)
+  (let ((beg-beg (make-marker))
+       (beg-end (make-marker))
+       (end-beg (make-marker))
+       (end-end (make-marker)))
+    (if (search-forward-regexp re-beg nil t)
+       (progn
+         (set-marker beg-beg (match-beginning 0))
+         (set-marker beg-end (match-end 0))
+         (if (search-forward-regexp re-end nil t)
+             (progn
+               (set-marker end-beg (match-beginning 0))
+               (set-marker end-end (match-end 0))
+               (list beg-beg beg-end end-beg end-end))
+           nil))
+      nil)))
+
+(defun dictem-postprocess-definition-hyperlinks-cyrlybr1 ()
+  (save-excursion
+    (goto-char (point-min))
+    (let ((regexp) (pos) (beg1) (beg2) (beg3) (end) (word))
+
+      (while (setq pos (dictem-find-brackets dictem-hyperlink-beginning
+                                            dictem-hyperlink-end))
+       (delete-region (nth 0 pos) (nth 1 pos))
+       (delete-region (nth 2 pos) (nth 3 pos))
+       (setq word (buffer-substring-no-properties (nth 1 pos) (nth 2 pos)))
+       (dictem-create-link
+        (nth 1 pos) (nth 2 pos)
+        'dictem-reference-definition-face
+        dictem-hyperlink-define-func
+        (list (cons 'word (dictem-replace-spaces word))
+              (cons 'dbname dictem-current-dbname))
+        '(link t))))))
+
+(defun dictem-postprocess-definition-hyperlinks-curlybr2 ()
   (save-excursion
     (goto-char (point-min))
     (let ((regexp
-          (concat dictem-hyperlink-beginning "\\([^{}|]+\\)" 
dictem-hyperlink-end
-                  "\\|"
-                  "^From [^\n]+\\[\\([^\n]+\\)\\]"
-                  "\\|"
-                  "\\(" dictem-hyperlink-beginning 
"\\([^{}|\n]+\\)|\\([^{}|\n]+\\)"
-                  dictem-hyperlink-end "\\)")))
+          (concat dictem-hyperlink-beginning "\\([^{}|\n]+\\)|\\([^{}|\n]+\\)"
+                  dictem-hyperlink-end)))
 
       (while (search-forward-regexp regexp nil t)
-       (cond ((match-beginning 1)
-              (let* ((beg (match-beginning 1))
-                     (end (match-end 1))
-                     (match-beg (match-beginning 0))
-                     (word (buffer-substring-no-properties beg end)))
-                (replace-match word t t)
-                (dictem-create-link
-                 match-beg (+ match-beg (length word))
-                 'dictem-reference-definition-face
-                 dictem-hyperlink-define-func
-                 (list (cons 'word (dictem-replace-spaces word))
-                       (cons 'dbname dictem-current-dbname))
-                 '(link t))
-                ))
-             ((match-beginning 2)
-              (if (null dictem-current-dbname)
-                  (setq dictem-current-dbname
-                        (dictem-replace-spaces
-                         (buffer-substring-no-properties (match-beginning 2)
-                                                         (match-end 2))))))
-             ((match-beginning 3)
-              (let* ((beg (match-beginning 5))
-                     (end (match-end 5))
-                     (match-beg (match-beginning 3))
-                     (repl-beg (match-beginning 4))
-                     (repl-end (match-end 4))
-                     (repl (buffer-substring-no-properties repl-beg repl-end))
-                     (word (buffer-substring-no-properties beg end)))
-                (replace-match repl t t)
-                (dictem-create-link
-                 match-beg (+ match-beg (length repl))
-                 'dictem-reference-definition-face
-                 dictem-hyperlink-define-func
-                 (list (cons 'word (dictem-replace-spaces word))
-                       (cons 'dbname dictem-current-dbname))
-                 '(link t))))
-             )))))
+       (let* ((beg (match-beginning 5))
+              (end (match-end 5))
+              (match-beg (match-beginning 3))
+              (repl-beg (match-beginning 4))
+              (repl-end (match-end 4))
+              (repl (buffer-substring-no-properties repl-beg repl-end))
+              (word (buffer-substring-no-properties beg end)))
+         (replace-match repl t t)
+         (dictem-create-link
+          match-beg (+ match-beg (length repl))
+          'dictem-reference-definition-face
+          dictem-hyperlink-define-func
+          (list (cons 'word (dictem-replace-spaces word))
+                (cons 'dbname dictem-current-dbname))
+          '(link t)))))))
+
+(defun dictem-postprocess-definition-hyperlinks ()
+  (dictem-postprocess-definition-hyperlinks-cyrlybr1)
+  (dictem-postprocess-definition-hyperlinks-curlybr2)
+;  (dictem-postprocess-definition-hyperlinks-curlybr2)
+  )
 
 (defun dictem-postprocess-match ()
   (save-excursion
@@ -1832,6 +1826,113 @@
              (kill-line 1))
            )))))
 
+(defun dictem-add-text-face-properties (start end face-add-props
+                                             &optional object)
+  (let (face-props)
+    (while (<= start end)
+      (progn
+       (setq face-props (get-text-property start 'face object))
+       (if (facep face-props)
+           (progn
+             (setq face-props nil)
+             (add-text-properties
+              start (+ 1 start)
+              (list 'face nil)
+              object)))
+       (add-text-properties
+        start (+ 1 start)
+        (list 'face (append face-props face-add-props))
+        object)
+       (setq start (+ start 1))))))
+
+(defun dictem-add-begendre-face-propertires (re-beg re-end face-properties)
+  (let ((bold-beg-beg (make-marker))
+       (bold-beg-end (make-marker))
+       (bold-end-beg (make-marker))
+       (bold-end-end (make-marker)))
+    (while (search-forward-regexp re-beg nil t)
+      (progn
+       (set-marker bold-beg-beg (match-beginning 0))
+       (set-marker bold-beg-end (match-end 0))
+       (if (search-forward-regexp re-end nil t)
+           (progn
+             (set-marker bold-end-beg (match-beginning 0))
+             (set-marker bold-end-end (match-end 0))
+             (dictem-add-text-face-properties
+              bold-beg-end (- bold-end-beg 1) face-properties)
+             (delete-region bold-beg-beg bold-beg-end)
+             (delete-region bold-end-beg bold-end-end)
+             ))))))
+
+(defun dictem-postprocess-stardict-definition ()
+  (interactive)
+
+  (goto-char (point-min))
+  (dictem-add-begendre-face-propertires
+   "<b>" "</b>" '(:weight bold))
+
+  (goto-char (point-min))
+  (dictem-add-begendre-face-propertires
+   "<k>" "</k>" '(:height 1.2 :foreground "white" :weight bold))
+
+  (goto-char (point-min))
+  (dictem-add-begendre-face-propertires
+   "<abr>" "</abr>" '(:weight bold :foreground "green"))
+
+  (goto-char (point-min))
+  (dictem-add-begendre-face-propertires
+   "<dtrn>" "</dtrn>" '())
+
+  (goto-char (point-min))
+  (dictem-add-begendre-face-propertires
+   "<c c=\"green\">" "</c>" '(:foreground "green"))
+
+  (goto-char (point-min))
+  (dictem-add-begendre-face-propertires
+   "<c c=\"brown\">" "</c>" '(:foreground "brown"))
+
+  (goto-char (point-min))
+  (dictem-add-begendre-face-propertires
+   "<c>" "</c>" '(:foreground "green"))
+
+  (goto-char (point-min))
+  (dictem-add-begendre-face-propertires
+   "<ex>" "</ex>" '(:foreground "BurlyWood"))
+
+  (goto-char (point-min))
+  (dictem-add-begendre-face-propertires
+   "<i>" "</i>" '(:slant "oblique"))
+
+  (goto-char (point-min))
+  (dictem-add-begendre-face-propertires
+   "<c c=\"blueviolet\">" "</c>" '(:foreground "lightblue"))
+
+  ; replaceing <tr> with [
+  (goto-char (point-min))
+  (while (search-forward-regexp "<tr>" nil t)
+    (replace-match "[" t t))
+
+  ; replaceing </tr> with ]
+  (goto-char (point-min))
+  (while (search-forward-regexp "</tr>" nil t)
+    (replace-match "]" t t))
+
+  ; replaceing <co> with (
+  (goto-char (point-min))
+  (while (search-forward-regexp "<co>" nil t)
+    (replace-match "" t t))
+
+  ; replaceing </co> with (
+  (goto-char (point-min))
+  (while (search-forward-regexp "</co>" nil t)
+    (replace-match "" t t))
+
+  (let ((dictem-hyperlink-beginning "<kref>")
+       (dictem-hyperlink-end "</kref>"))
+    (dictem-postprocess-definition-hyperlinks-cyrlybr1))
+
+  )
+
 ;;;;;       On-Click Functions     ;;;;;
 (defun dictem-define-on-press ()
   "Is called upon pressing Enter."

Reply via email to