From 9233bd90bbfe50b3b819f805d2f9f3c5722a0320 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Fri, 25 Nov 2022 16:07:25 +1100 Subject: fixing FIXMEs --- luwak-org.el | 38 ++++++++++++++++++++++++++++++++++++++ luwak.el | 19 +++---------------- 2 files changed, 41 insertions(+), 16 deletions(-) create mode 100644 luwak-org.el diff --git a/luwak-org.el b/luwak-org.el new file mode 100644 index 0000000..1c1b7c1 --- /dev/null +++ b/luwak-org.el @@ -0,0 +1,38 @@ +;;; luwak-org.el --- org integration for luwak. -*- lexical-binding: t; -*- + +;; Copyright (C) 2022 Free Software Foundation, Inc. +;; +;; This file is part of luwak. +;; +;; luwak is free software: you can redistribute it and/or modify it under +;; the terms of the GNU Affero General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; luwak 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 Affero General +;; Public License for more details. +;; +;; You should have received a copy of the GNU Affero General Public +;; License along with luwak. If not, see . + +;;; Commentary: + +;;; Code: + +(require 'org) +(require 'luwak) + +(defun luwak-org-store-link () + (when (derived-mode-p 'luwak-mode) + (org-link-store-props + :type "luwak" + :link (plist-get luwak-data :url) + :description (luwak-guess-title)))) + +(org-link-set-parameters "luwak" + :follow #'luwak-open + :store #'luwak-org-store-link) + +(provide 'luwak-org) diff --git a/luwak.el b/luwak.el index a283e13..03c40a0 100644 --- a/luwak.el +++ b/luwak.el @@ -6,7 +6,7 @@ ;; Version: 0 ;; Keywords: web-browser, lynx, html, tor ;; Package-Requires: ((emacs "28")) -;; Package-Type: +;; Package-Type: multi ;; Homepage: https://g.ypei.me/luwak.git ;; Copyright (C) 2022 Free Software Foundation, Inc. @@ -125,26 +125,13 @@ non-nill, swap the tor-switch in prefix-arg effect." (buffer-substring-no-properties (1- (point)) (progn (end-of-line 1) (point)))))) -(defun luwak-org-store-link () - (when (derived-mode-p 'luwak-mode) - (org-link-store-props - :type "luwak" - :link (plist-get luwak-data :url) - :description (luwak-guess-title)))) - -;; FIXME: `org' is always available, so this should never fail! -(when (require 'org nil t) - (org-link-set-parameters "luwak" - :follow #'luwak-open - :store #'luwak-org-store-link)) - ;;;###autoload (defun luwak-open (url) "Open URL in luwak." (interactive (list (if luwak-use-history - (car ;FIXME: Why throw away everything after space? + (car (split-string (completing-read "Url to open: " (luwak-history-collection-from-file)))) @@ -342,7 +329,7 @@ non-nill, swap the tor-switch in prefix-arg effect." (goto-char (point-min)) (re-search-forward "^References\n\n\\(\\ *Visible links:\n\\)?" nil t) (delete-region (point-min) (match-end 0)) - (seq-filter #'identity ;`delq nil' ? + (delq nil (mapcar (lambda (s) (when (string-match "^\\ *\\([0-9]+\\)\\. \\(.*\\)" s) (concat (match-string 1 s) " " (match-string 2 s)))) -- cgit v1.2.3