diff options
| author | Franck Cuny <franck@fcuny.net> | 2022-03-23 19:23:34 -0700 |
|---|---|---|
| committer | Franck Cuny <franck@fcuny.net> | 2022-03-23 19:23:34 -0700 |
| commit | 52023b34601a9afe4fd67bbb2f0b8c17b3b64d65 (patch) | |
| tree | 993903dcb044f37b32c0cd8250cadba55ebaa952 /emacs/elisp/my-web.el | |
| parent | init: simplify loading libraries (diff) | |
| download | emacs.d-52023b34601a9afe4fd67bbb2f0b8c17b3b64d65.tar.gz | |
functions: move custom functions to libraries
Diffstat (limited to '')
| -rw-r--r-- | emacs/elisp/my-web.el | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/emacs/elisp/my-web.el b/emacs/elisp/my-web.el new file mode 100644 index 0000000..12e5c97 --- /dev/null +++ b/emacs/elisp/my-web.el @@ -0,0 +1,21 @@ +;;; my-web.el --- Functions related to web interactions +;;; Commentary: +;;; Code: + +(require 'my-strings) + +(defun fcuny/get-page-title (url) + "Make URL into an 'org-mode' link." + (let ((title)) + (with-current-buffer (url-retrieve-synchronously url) + (goto-char (point-min)) + (re-search-forward "<title>\\([^<]*\\)</title>" nil t 1) + (setq title (match-string 1)) + (goto-char (point-min)) + (re-search-forward "charset=\\([-0-9a-zA-Z]*\\)" nil t 1) + (my/string-replace " " " " + (decode-coding-string title 'utf-8)) + (concat "[[" url "][" title "]]")))) + +(provide 'my-web) +;;; my-web.el ends here |
