]> git.eshelyaron.com Git - emacs.git/commitdiff
Renamed link.el
authorTorsten Hilbrich <torsten.hilbrich@gmx.net>
Mon, 5 Oct 2020 05:11:25 +0000 (07:11 +0200)
committerTorsten Hilbrich <torsten.hilbrich@gmx.net>
Thu, 8 Oct 2020 03:56:31 +0000 (05:56 +0200)
* lisp/net/link.el: Renamed to connection-link.el, also prefixing all
functions with "dictionary-" prefix
* lisp/net/dictionary.el: Adapt to renamed functions

lisp/net/dictionary-link.el [new file with mode: 0644]
lisp/net/dictionary.el
lisp/net/link.el [deleted file]

diff --git a/lisp/net/dictionary-link.el b/lisp/net/dictionary-link.el
new file mode 100644 (file)
index 0000000..86e853e
--- /dev/null
@@ -0,0 +1,126 @@
+;;; dictionary-link.el --- Hypertext links in text buffers
+
+;; Author: Torsten Hilbrich <torsten.hilbrich@gmx.net>
+;; Keywords: interface, hypermedia
+;; Version: 1.11
+
+;; This file 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, or (at your option)
+;; any later version.
+
+;; This file 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 GNU Emacs; see the file COPYING.  If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; This file contains functions for using links in buffers.  A link is
+;; a part of the buffer marked with a special face, beeing
+;; hightlighted while the mouse points to it and beeing activated when
+;; pressing return or clicking the button2.
+
+;; Which each link a function and some data are associated.  Upon
+;; clicking the function is called with the data as only
+;; argument. Both the function and the data are stored in text
+;; properties.
+;;
+;; 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:
+
+(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."
+  (let ((properties `(face ,face
+                      mouse-face highlight
+                      link t
+                      link-data ,data
+                      help-echo ,help
+                      link-function ,function)))
+    (remove-text-properties start end properties)
+    (add-text-properties start end properties)))
+
+(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)
+    (dictionary-link-create-link start (point) face function data help)))
+
+(defun dictionary-link-selected (&optional all)
+  "Is called upon clicking or otherwise visiting the link."
+  (interactive)
+
+  (let* ((properties (text-properties-at (point)))
+         (function (plist-get properties 'link-function))
+         (data (plist-get properties 'link-data)))
+    (if function
+        (funcall function data all))))
+
+(defun dictionary-link-selected-all ()
+  "Called for meta clicking the link"
+  (interactive)
+  (dictionary-link-selected 'all))
+
+(defun dictionary-link-mouse-click (event &optional all)
+  "Is called upon clicking the link."
+  (interactive "@e")
+
+  (mouse-set-point event)
+  (dictionary-link-selected))
+
+(defun dictionary-link-mouse-click-all (event)
+  "Is called upon meta clicking the link."
+  (interactive "@e")
+
+  (mouse-set-point event)
+  (dictionary-link-selected-all))
+
+(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)))
+    (if pos
+        (if (text-property-any pos (min (1+ pos) (point-max)) 'link t)
+            pos
+          (next-single-property-change pos 'link))
+      nil)))
+
+
+(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)))
+    (if pos
+        (if (text-property-any pos (1+ pos) 'link t)
+            pos
+          (let ((val (previous-single-property-change pos 'link)))
+            (if val
+                val
+              (text-property-any (point-min) (1+ (point-min)) 'link t))))
+      nil)))
+
+(defun dictionary-link-initialize-keymap (keymap)
+  "Defines the necessary bindings inside keymap"
+
+  (if (and (boundp 'running-xemacs) running-xemacs)
+      (progn
+        (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 'dictionary-link)
+;;; dictionary-link.el ends here
index 7dd88e6e42e6aa7e6a8f3134e2b3ac210feb93be..4b2f25c26b41b09af4d7fdcbdedad7add56faf49 100644 (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"))))
diff --git a/lisp/net/link.el b/lisp/net/link.el
deleted file mode 100644 (file)
index 30eadb1..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-;;; link.el --- Hypertext links in text buffers
-
-;; Author: Torsten Hilbrich <torsten.hilbrich@gmx.net>
-;; Keywords: interface, hypermedia
-;; Version: 1.11
-
-;; This file 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, or (at your option)
-;; any later version.
-
-;; This file 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 GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
-
-;;; Commentary:
-
-;; This file contains functions for using links in buffers.  A link is
-;; a part of the buffer marked with a special face, beeing
-;; hightlighted while the mouse points to it and beeing activated when
-;; pressing return or clicking the button2.
-
-;; Which each link a function and some data are associated.  Upon
-;; clicking the function is called with the data as only
-;; 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
-
-;;; Code:
-
-(eval-when-compile
-  (require 'cl))
-
-(defun 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."
-  (let ((properties `(face ,face
-                      mouse-face highlight
-                      link t
-                      link-data ,data
-                      help-echo ,help
-                      link-function ,function)))
-    (remove-text-properties start end properties)
-    (add-text-properties start end properties)))
-
-(defun 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)))
-
-(defun link-selected (&optional all)
-  "Is called upon clicking or otherwise visiting the link."
-  (interactive)
-
-  (let* ((properties (text-properties-at (point)))
-         (function (plist-get properties 'link-function))
-         (data (plist-get properties 'link-data)))
-    (if function
-        (funcall function data all))))
-
-(defun link-selected-all ()
-  "Called for meta clicking the link"
-  (interactive)
-  (link-selected 'all))
-
-(defun link-mouse-click (event &optional all)
-  "Is called upon clicking the link."
-  (interactive "@e")
-
-  (mouse-set-point event)
-  (link-selected))
-
-(defun link-mouse-click-all (event)
-  "Is called upon meta clicking the link."
-  (interactive "@e")
-
-  (mouse-set-point event)
-  (link-selected-all))
-
-(defun 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)))
-    (if pos
-        (if (text-property-any pos (min (1+ pos) (point-max)) 'link t)
-            pos
-          (next-single-property-change pos 'link))
-      nil)))
-
-
-(defun 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)))
-    (if pos
-        (if (text-property-any pos (1+ pos) 'link t)
-            pos
-          (let ((val (previous-single-property-change pos 'link)))
-            (if val
-                val
-              (text-property-any (point-min) (1+ (point-min)) 'link t))))
-      nil)))
-
-(defun 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))
-
-(provide 'link)
-;;; link.el ends here