From cd62bb147b15d052d52c5dc0f6277902efa7a61e Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Sun, 23 Jul 2023 17:01:24 +1000 Subject: Fixing copyright and flymake complaints. --- wiki-utils.el | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'wiki-utils.el') diff --git a/wiki-utils.el b/wiki-utils.el index ae61d4d..257db5d 100644 --- a/wiki-utils.el +++ b/wiki-utils.el @@ -1,6 +1,6 @@ ;;; wiki-utils.el -- wiki utility functions -*- lexical-binding: t -*- -;; Copyright (C) 2023 Free Software Foundation. +;; Copyright (C) 2023 Free Software Foundation, Inc. ;; Author: Yuchen Pei ;; Package-Requires: ((emacs "28.2")) @@ -31,13 +31,14 @@ "Path to local directory of wiki files.") (defvar wiki-fetch-prefer-local t - "If non-nil, visit the local file if exists when instructed for -fetching.") + "If non-nil, visit the local file if exists when fetching.") (defun wiki-fetch-url (url dir &optional callback title) - "Fetch URL asynchronously. + "Fetch URL asynchronously to a file in DIR. -Then calls CALLBACK which is a closure taking no argument." +Then call CALLBACK which is a closure taking no argument. + +A non-nil TITLE overrides title inferred from the url." (interactive "sURL: ") (let ((file-name (expand-file-name (or title (wiki-make-file-name-from-url url)) @@ -49,6 +50,9 @@ Then calls CALLBACK which is a closure taking no argument." ) (defun wiki-fetch-url-save-and-switch (status file-name) + "Fetch url to FILE-NAME if STATUS is ok. + +And switch to the corresponding buffer." (when (plist-get status :error) (error "Wiki fetch failed: %s" (plist-get status :error))) (wiki-delete-http-header) @@ -65,13 +69,20 @@ Then calls CALLBACK which is a closure taking no argument." ) (defun wiki-delete-http-header () + "Delete the http header in current buffer. + +Assuming the current buffer to be a `url-retrieve' response buffer." (delete-region (point-min) (progn (wiki-skip-http-header) (point)))) (defun wiki-skip-http-header () + "Skip the http header in current buffer. + +Assuming the current buffer to be a `url-retrieve' response buffer." (goto-char (point-min)) (re-search-forward "\r?\n\r?\n")) (defun wiki-make-file-name-from-url (url) + "Make a file name from URL." (file-name-nondirectory (directory-file-name (car (url-path-and-query (url-generic-parse-url @@ -146,9 +157,10 @@ Each item is in the form of (identifier . properties), where identifier is a symbol, and properties is a plist of the site. One of the sites is (local), meaning a local filesystem.") -(defun wiki-site-fetcher (wiki-site) - (if wiki-site - (intern (format "wiki-%s-fetch" wiki-site)) +(defun wiki-site-fetcher (site-id) + "Return the fetcher function for wiki site with SITE-ID." + (if site-id + (intern (format "wiki-%s-fetch" site-id)) 'wiki-find-file)) (provide 'wiki-utils) -- cgit v1.2.3