Update -- Reorganise Keybindings
[syinit] / 12-misc.el
index 2248841..0e3b0df 100644 (file)
@@ -5,7 +5,7 @@
 ;;     Author: Steve Youngs <steve@sxemacs.org>
 ;; Maintainer: Steve Youngs <steve@sxemacs.org>
 ;;    Created: <2007-12-02>
-;; Time-stamp: <Thursday 08 Apr 2021 10:52:03 (steve)>
+;; Time-stamp: <Monday 12 Apr 2021 12:18:29 (steve)>
 ;;   Download: <https://downloads.sxemacs.org/SYinits>
 ;;   HTMLised: <https://www.sxemacs.org/SYinits/12-misc.html>
 ;;   Git Repo: git clone https://git.sxemacs.org/syinit
   (interactive "p")
   (cond ((looking-at "[([{]") (forward-sexp 1) (backward-char))
         ((looking-at "[])}]") (forward-char) (backward-sexp 1))))
-(global-set-key '(control f1) 'match-paren)
 
 ;:*======================
 ;:* Inserting elisp Comments
   (insert ";:*=======================\n")
   (insert ";:* " (setq str (read-input "Comment: ")) "\n")
   (insert "\n"))
-(global-set-key '(control f3) 'elispcomment)
 
 ;:*======================
 ;:* Time-Stamp
       (let ((stream (make-media-stream :file file)))
        (play-media-stream stream)))))
 
-(define-key dired-mode-map [(control ?c) ?p] #'sy-dired-play-audio)
-
 ;(setq dired-use-ls-dired t)
 ;(setq dired-listing-switches "-alih")
 
     (igrep-find "grep" tagname (concat dir "/*"))))
 
 ;:*=======================
-;:* Google
-(require 'google-query)
-(setq google-query-mirror "https://www.google.com.au"
-      google-query-result-count 100)
-(global-set-key [XF86Search] 'google-query)
-(global-set-key [(control XF86Search)] 'google-query-region)
+;:* Google (see: DuckDuckGo below)
+; (require 'google-query)
+; (setq google-query-mirror "https://www.google.com.au"
+;       google-query-result-count 100)
 
 ;:*=======================
 ;:* What the fuck does that acronym mean?
@@ -712,8 +706,6 @@ finally do `\\[yank]' and you'd get...
        (kill-append (buffer-substring start end) 'before)
       (kill-append (buffer-substring start end) nil))))
 
-(global-set-key [(meta ?W)] 'sy-add-to-kill)
-
 ;:*=======================
 ;:* DNS
 (add-to-list 'auto-mode-alist '("/var/chroot/named/etc/zones/.*$" . dns-mode))
@@ -914,8 +906,6 @@ files are assigned what numbers."
         (expanded (expand-file-name lib lisp-initd-dir)))
     (find-file-other-window expanded codesys)))
 
-(global-set-key [(control ?x) ?4 ?i] #'sy-init-file-other-window)
-
 ;:*=======================
 ;:* "Active" menubar
 ;; Nifty little thing that hides the menubar and makes it visible when
@@ -953,8 +943,6 @@ Till next time...<br />
 (number-to-register 0 ?n)
 (defalias 'numpoints
   (read-kbd-macro "2*RET 2*SPC C-x r + n C-x r i n C-e ) SPC"))
-(global-set-key [(control ?c) (control ?n)] #'numpoints)
-(define-key message-mode-map [(hyper ?n)] #'numpoints)
 
 ;:*=======================
 ;:* Do things with environment variables let-bound
@@ -1007,6 +995,31 @@ anything about MIME types."
 
 (fset #'browse-url-of-file #'sy-browse-url-of-file)
 
+;:*=======================
+;:* Search DuckDuckGo
+(defun ddg-search (string)
+  "Search DuckDuckGo for STRING.
+
+STRING is truncated at 500 characters to stay within DuckDuckGo's
+limits. The results are displayed in your default browser via
+`browse-url'"
+  (interactive "sSearch DuckDuckGo for: ")
+  (let* ((baseurl "https://duckduckgo.com/?q=")
+        (str (url-hexify-string
+              (truncate-string-to-width string 500))))
+    (browse-url (concat baseurl str))))
+
+(defun ddg-search-region (beg end)
+  "Search DuckDuckGo for the string BEG END.
+
+The search string is truncated at 500 characters to stay within
+DuckDuckGo's limits. The results are displayed in your default
+browser via `browse-url'"
+  (interactive "r")
+  (let ((str (buffer-substring-no-properties beg end)))
+    (zmacs-deactivate-region)
+    (ddg-search str)))
+
 ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*
 (message "miscellaneous initialised")