Renamed link.el

* lisp/net/link.el: Renamed to connection-link.el, also prefixing all
functions with "dictionary-" prefix
* lisp/net/dictionary.el: Adapt to renamed functions
This commit is contained in:
Torsten Hilbrich 2020-10-05 07:11:25 +02:00
parent 658ec3ccee
commit e2ebffdd62
2 changed files with 71 additions and 74 deletions

View file

@ -1,4 +1,4 @@
;;; link.el --- Hypertext links in text buffers
;;; dictionary-link.el --- Hypertext links in text buffers
;; Author: Torsten Hilbrich <torsten.hilbrich@gmx.net>
;; Keywords: interface, hypermedia
@ -31,15 +31,12 @@
;; argument. Both the function and the data are stored in text
;; properties.
;;
;; link-create-link - insert a new link for the text in the given range
;; link-initialize-keymap - install the keybinding for selecting links
;; dictionary-link-create-link - insert a new link for the text in the given range
;; dictionary-link-initialize-keymap - install the keybinding for selecting links
;;; Code:
(eval-when-compile
(require 'cl))
(defun link-create-link (start end face function &optional data help)
(defun dictionary-link-create-link (start end face function &optional data help)
"Create a link in the current buffer starting from `start' going to `end'.
The `face' is used for displaying, the `data' are stored together with the
link. Upon clicking the `function' is called with `data' as argument."
@ -52,15 +49,15 @@ link. Upon clicking the `function' is called with `data' as argument."
(remove-text-properties start end properties)
(add-text-properties start end properties)))
(defun link-insert-link (text face function &optional data help)
(defun dictionary-link-insert-link (text face function &optional data help)
"Insert the `text' at point to be formatted as link.
The `face' is used for displaying, the `data' are stored together with the
link. Upon clicking the `function' is called with `data' as argument."
(let ((start (point)))
(insert text)
(link-create-link start (point) face function data help)))
(dictionary-link-create-link start (point) face function data help)))
(defun link-selected (&optional all)
(defun dictionary-link-selected (&optional all)
"Is called upon clicking or otherwise visiting the link."
(interactive)
@ -70,26 +67,26 @@ link. Upon clicking the `function' is called with `data' as argument."
(if function
(funcall function data all))))
(defun link-selected-all ()
(defun dictionary-link-selected-all ()
"Called for meta clicking the link"
(interactive)
(link-selected 'all))
(dictionary-link-selected 'all))
(defun link-mouse-click (event &optional all)
(defun dictionary-link-mouse-click (event &optional all)
"Is called upon clicking the link."
(interactive "@e")
(mouse-set-point event)
(link-selected))
(dictionary-link-selected))
(defun link-mouse-click-all (event)
(defun dictionary-link-mouse-click-all (event)
"Is called upon meta clicking the link."
(interactive "@e")
(mouse-set-point event)
(link-selected-all))
(dictionary-link-selected-all))
(defun link-next-link ()
(defun dictionary-link-next-link ()
"Return the position of the next link or nil if there is none"
(let* ((pos (point))
(pos (next-single-property-change pos 'link)))
@ -100,7 +97,7 @@ link. Upon clicking the `function' is called with `data' as argument."
nil)))
(defun link-prev-link ()
(defun dictionary-link-prev-link ()
"Return the position of the previous link or nil if there is none"
(let* ((pos (point))
(pos (previous-single-property-change pos 'link)))
@ -113,17 +110,17 @@ link. Upon clicking the `function' is called with `data' as argument."
(text-property-any (point-min) (1+ (point-min)) 'link t))))
nil)))
(defun link-initialize-keymap (keymap)
(defun dictionary-link-initialize-keymap (keymap)
"Defines the necessary bindings inside keymap"
(if (and (boundp 'running-xemacs) running-xemacs)
(progn
(define-key keymap [button2] 'link-mouse-click)
(define-key keymap [(meta button2)] 'link-mouse-click-all))
(define-key keymap [mouse-2] 'link-mouse-click)
(define-key keymap [M-mouse-2] 'link-mouse-click-all))
(define-key keymap "\r" 'link-selected)
(define-key keymap "\M-\r" 'link-selected-all))
(define-key keymap [button2] 'dictionary-link-mouse-click)
(define-key keymap [(meta button2)] 'dictionary-link-mouse-click-all))
(define-key keymap [mouse-2] 'dictionary-link-mouse-click)
(define-key keymap [M-mouse-2] 'dictionary-link-mouse-click-all))
(define-key keymap "\r" 'dictionary-link-selected)
(define-key keymap "\M-\r" 'dictionary-link-selected-all))
(provide 'link)
;;; link.el ends here
(provide 'dictionary-link)
;;; dictionary-link.el ends here

View file

@ -40,7 +40,7 @@
(require 'easymenu)
(require 'custom)
(require 'dictionary-connection)
(require 'link)
(require 'dictionary-link)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Stuff for customizing.
@ -434,7 +434,7 @@ by the choice value:
(define-key dictionary-mode-map " " 'scroll-up)
(define-key dictionary-mode-map [(meta space)] 'scroll-down)
(link-initialize-keymap dictionary-mode-map))
(dictionary-link-initialize-keymap dictionary-mode-map))
(defmacro dictionary-reply-code (reply)
"Return the reply code stored in `reply'."
@ -713,37 +713,37 @@ This function knows about the special meaning of quotes (\")"
(erase-buffer)
(if dictionary-create-buttons
(progn
(link-insert-link "[Back]" 'dictionary-button-face
'dictionary-restore-state nil
"Mouse-2 to go backwards in history")
(dictionary-link-insert-link "[Back]" 'dictionary-button-face
'dictionary-restore-state nil
"Mouse-2 to go backwards in history")
(insert " ")
(link-insert-link "[Search Definition]"
'dictionary-button-face
'dictionary-search nil
"Mouse-2 to look up a new word")
(dictionary-link-insert-link "[Search Definition]"
'dictionary-button-face
'dictionary-search nil
"Mouse-2 to look up a new word")
(insert " ")
(link-insert-link "[Matching words]"
'dictionary-button-face
'dictionary-match-words nil
"Mouse-2 to find matches for a pattern")
(dictionary-link-insert-link "[Matching words]"
'dictionary-button-face
'dictionary-match-words nil
"Mouse-2 to find matches for a pattern")
(insert " ")
(link-insert-link "[Quit]" 'dictionary-button-face
'dictionary-close nil
"Mouse-2 to close this window")
(dictionary-link-insert-link "[Quit]" 'dictionary-button-face
'dictionary-close nil
"Mouse-2 to close this window")
(insert "\n ")
(link-insert-link "[Select Dictionary]"
'dictionary-button-face
'dictionary-select-dictionary nil
"Mouse-2 to select dictionary for future searches")
(dictionary-link-insert-link "[Select Dictionary]"
'dictionary-button-face
'dictionary-select-dictionary nil
"Mouse-2 to select dictionary for future searches")
(insert " ")
(link-insert-link "[Select Match Strategy]"
'dictionary-button-face
'dictionary-select-strategy nil
"Mouse-2 to select matching algorithm")
(dictionary-link-insert-link "[Select Match Strategy]"
'dictionary-button-face
'dictionary-select-strategy nil
"Mouse-2 to select matching algorithm")
(insert "\n\n")))
(setq dictionary-marker (point-marker)))
@ -821,10 +821,10 @@ The word is taken from the buffer, the `dictionary' is given as argument."
(setq word (replace-match "" t t word)))
(unless (equal word displayed-word)
(link-create-link start end 'dictionary-reference-face
call (cons word dictionary)
(concat "Press Mouse-2 to lookup \""
word "\" in \"" dictionary "\"")))))
(dictionary-link-create-link start end 'dictionary-reference-face
call (cons word dictionary)
(concat "Press Mouse-2 to lookup \""
word "\" in \"" dictionary "\"")))))
(defun dictionary-select-dictionary (&rest ignored)
"Save the current state and start a dictionary selection"
@ -882,11 +882,11 @@ If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
(if dictionary
(if (equal dictionary "--exit--")
(insert "(end of default search list)\n")
(link-insert-link (concat dictionary ": " translated)
'dictionary-reference-face
'dictionary-set-dictionary
(cons dictionary description)
"Mouse-2 to select this dictionary")
(dictionary-link-insert-link (concat dictionary ": " translated)
'dictionary-reference-face
'dictionary-set-dictionary
(cons dictionary description)
"Mouse-2 to select this dictionary")
(insert "\n")))))
(defun dictionary-set-dictionary (param &optional more)
@ -918,10 +918,10 @@ If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
(error "Unknown server answer: %s" (dictionary-reply reply)))
(dictionary-pre-buffer)
(insert "Information on dictionary: ")
(link-insert-link description 'dictionary-reference-face
'dictionary-set-dictionary
(cons dictionary description)
"Mouse-2 to select this dictionary")
(dictionary-link-insert-link description 'dictionary-reference-face
'dictionary-set-dictionary
(cons dictionary description)
"Mouse-2 to select this dictionary")
(insert "\n\n")
(setq reply (dictionary-read-answer))
(insert reply)
@ -969,9 +969,9 @@ If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
(description (cadr list)))
(if strategy
(progn
(link-insert-link description 'dictionary-reference-face
'dictionary-set-strategy strategy
"Mouse-2 to select this matching algorithm")
(dictionary-link-insert-link description 'dictionary-reference-face
'dictionary-set-strategy strategy
"Mouse-2 to select this matching algorithm")
(insert "\n")))))
(defun dictionary-set-strategy (strategy &rest ignored)
@ -1071,11 +1071,11 @@ If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
(mapc (lambda (word)
(setq word (dictionary-decode-charset word dictionary))
(insert " ")
(link-insert-link word
'dictionary-reference-face
'dictionary-new-search
(cons word dictionary)
"Mouse-2 to lookup word")
(dictionary-link-insert-link word
'dictionary-reference-face
'dictionary-new-search
(cons word dictionary)
"Mouse-2 to lookup word")
(insert "\n")) (reverse word-list))
(insert "\n")))
list))
@ -1133,7 +1133,7 @@ It presents the word at point as default input and allows editing it."
(defun dictionary-next-link ()
"Place the cursor to the next link."
(interactive)
(let ((pos (link-next-link)))
(let ((pos (dictionary-link-next-link)))
(if pos
(goto-char pos)
(error "There is no next link"))))
@ -1141,7 +1141,7 @@ It presents the word at point as default input and allows editing it."
(defun dictionary-prev-link ()
"Place the cursor to the previous link."
(interactive)
(let ((pos (link-prev-link)))
(let ((pos (dictionary-link-prev-link)))
(if pos
(goto-char pos)
(error "There is no previous link"))))