summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-03-27 00:23:42 +0000
committerjao <jao@gnu.org>2021-03-27 00:23:42 +0000
commit431f7498b64f3db98b4836e1aa971b0424fd0531 (patch)
tree273a7a28486b643c0d1431458245e4b4792a6137
parentb0f89825a5958a33c5222caaf6b9d09f904f6ead (diff)
downloadelibs-431f7498b64f3db98b4836e1aa971b0424fd0531.tar.gz
elibs-431f7498b64f3db98b4836e1aa971b0424fd0531.tar.bz2
more browse-url clean ups
-rw-r--r--init.org54
1 files changed, 19 insertions, 35 deletions
diff --git a/init.org b/init.org
index 02d8cff..d065291 100644
--- a/init.org
+++ b/init.org
@@ -869,8 +869,6 @@
(company-transformers '(company-sort-by-occurrence)))
:config
- (add-hook 'company-mode-hook (lambda () (setq company-lighter-base "")))
-
;; Prevent non-matching input (which will dismiss the completions
;; menu), but only if the user interacts explicitly with Company.
(setq company-require-match #'company-explicit-action-p)
@@ -2103,15 +2101,12 @@
* Browsing
*** Variables
#+begin_src emacs-lisp
- (require 'browse-url)
-
(defvar jao-browse-download-dir jao-sink-dir)
(defvar jao-browse-doc-use-emacs-p t)
(defvar jao-browse-url-function nil)
(defvar jao-browse-url-external-function nil)
- (setq browse-url-generic-program (jao-d-l "open" "~/bin/firehog"))
- #+end_src
-*** Helpers
+ #+end_src
+*** URL around point
#+BEGIN_SRC emacs-lisp
(defun jao-url-around-point (&optional current-url)
(or (and (fboundp 'w3m-anchor) (w3m-anchor))
@@ -2122,30 +2117,10 @@
(or (and (fboundp 'w3m-anchor) (w3m-anchor))
(and (derived-mode-p 'eww-mode) (plist-get eww-data :url))))))
- (defun jao--fln (url)
- (shell-quote-argument
- (if (string-match "^[^:]*:/*?\\(/?[^/].*\\)" url)
- (match-string-no-properties 1 url)
- url)))
-
- (defun jao--run (cmd url &rest flags)
- (start-process-shell-command
- cmd nil (format "%s %s %s"
- cmd
- (or (mapconcat 'shell-quote-argument flags " ") "")
- (jao--fln url))))
-
- (defun jao--view-pdf/ps (url)
- (when (not window-system)
- (select-frame (make-frame-on-display (getenv "DISPLAY")
- '((height . 55)))))
- (find-file (jao--fln url)))
-
(defun jao--url-prompt ()
(let* ((def (jao-url-around-point t))
(prompt (concat "URL" (if def (format " (%s): " def) ": "))))
(read-string prompt nil nil def)))
-
#+END_SRC
*** Downloads using wget
#+BEGIN_SRC emacs-lisp
@@ -2188,7 +2163,7 @@
(define-key embark-url-map (kbd "d") #'jao-download))
#+END_SRC
-*** Video downloads and playing
+*** Video
#+BEGIN_SRC emacs-lisp
(defvar jao-video--url-rx
(format "^https?://\\(?:www\\.\\)?%s/.+"
@@ -2224,6 +2199,9 @@
#+END_SRC
*** Browse URL
#+BEGIN_SRC emacs-lisp
+ (require 'browse-url)
+
+ (setq browse-url-generic-program "~/bin/firehog")
(defun jao-browse-with-external-browser (&rest url)
"Browse with external hogging"
@@ -2238,16 +2216,19 @@
(browse-url-generic url))))
(setq jao-browse-url-external-function 'jao-browse-with-external-browser)
+ (defun jao--fln (url)
+ (shell-quote-argument
+ (if (string-match "^[^:]*:/*?\\(/?[^/].*\\)" url)
+ (match-string-no-properties 1 url)
+ url)))
+
(defun jao--browse-doc (url search &optional no-add)
(let* ((url (substring-no-properties url))
(file (jao--fln url)))
(when file
(unless (file-exists-p file)
(error "File %s does not exist" file))
- (if window-system
- (jao-open-doc file)
- (set-process-sentinel (jao--run "see" file)
- (jao--browse-sentinel url))))))
+ (jao-open-doc file))))
(defun jao--make-file-rx (exts)
(format "file:/?/?.+\\.%s$" (regexp-opt exts)))
@@ -2266,14 +2247,17 @@
(mapconcat 'identity jao-browse-url-wget-exts "\\|\\.")
"\\)\\'"))
- (defun jao--see (url &rest r) (jao--run "see" url))
+ (defun jao--see (url &rest _r)
+ (start-process-shell-command "see" nil (format "see %s" (jao--fln url))))
+
+ (defun jao--find-file-other-window (url &rest _)
+ (find-file-other-window (jao--fln url)))
(setq browse-url-handlers
`((,jao--doc-exts . jao--browse-doc)
(,jao--see-exts . jao--see)
("^file://?.+\\.html?$" . ,jao-browse-url-function)
- ("^file://?" . (lambda (url &rest r)
- (find-file-other-window (jao--fln url))))
+ ("^file://?" . jao--find-file-other-window)
("^https?://.*\\.slack\\..*" . ,jao-browse-url-external-function)
("^https?://.*\\.gotomeeting\\.com\\.*" . browse-url-chrome)
("^https?://meet\\.google\\.com\\.*" . ,jao-browse-url-external-function)