From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: How to contribute new package to GNU ELPA? Date: Sat, 19 Dec 2020 01:22:59 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20889"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Emacs developers To: stardiviner Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Dec 19 07:24:15 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kqVf5-0005M1-HY for ged-emacs-devel@m.gmane-mx.org; Sat, 19 Dec 2020 07:24:15 +0100 Original-Received: from localhost ([::1]:54310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqVf4-0005lN-K5 for ged-emacs-devel@m.gmane-mx.org; Sat, 19 Dec 2020 01:24:14 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqVe1-0005Kv-1s for emacs-devel@gnu.org; Sat, 19 Dec 2020 01:23:09 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:26280) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqVdy-00072A-1G for emacs-devel@gnu.org; Sat, 19 Dec 2020 01:23:08 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 69554100229; Sat, 19 Dec 2020 01:23:04 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 3499D1000CF; Sat, 19 Dec 2020 01:23:01 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1608358981; bh=+MuHMOJmncTj3lUfmP97R6LqtNHhwJBhMt7+bGWfrMM=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=i7C0DIRaH2YN04TzGpax8aC7kLkZdYgyHadmFiMIKX03wcY2xJEBZHGhv4gN3+hxl OiQCTprrvJPzOeGiPkVtYm6cuOJSugj0Ztw5Df8fbHvUzvbCXP1gd4a/FRbDPdtk8n +yzsYHk+senSBEkY83CyACqZb7OjAGz09FO9nUv1J8oUfr9eUbywtl/SQUsJHC4Stv 2dkNoGOddRCA+qjIH07oljr1QkSdOYaUlLhp8lsT6iSOlk+OVCwsTTXEwuRxywfIOx 5Dth+JvCTKoP8nfnrQoAw7gI+tZUMEE4xAcETf25s6ag5OwceMDy07ijtPcsGCiMCb Zo7hr4YRi//Pw== Original-Received: from alfajor (69-165-136-52.dsl.teksavvy.com [69.165.136.52]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id E97B81203CF; Sat, 19 Dec 2020 01:23:00 -0500 (EST) In-Reply-To: (stardiviner's message of "Thu, 17 Dec 2020 20:11:39 +0800") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:261233 Archived-At: stardiviner [2020-12-17 20:11:39] wrote: > As this issue https://github.com/stardiviner/kiwix.el/issues/3 suggested. > I would like to contribute my package kiwix.el to GNU ELPA. I've just started to look at it. I have done some of the preliminary work, but there are some problems to solve: 1- The package uses `request` which is neither in Emacs nor in GNU ELPA. 2- The PNG images which are useful for the Homepage make the package much larger for no good reason, so I think we should add a `.elpaignore` file so as not to include those PNG imagines in the package's tarball. 3- Even with `request`, compiling the package fails because `org-kiwix.el` requirex `kiwix` and loading `kiwix` signal an error: (file-missing "Opening directory" "Aucun fichier ou dossier de ce type" "/.www.kiwix.org/kiwix") So, I think `file-accessible-directory-p` is not the function you want to use. The patch below fixes some of those problems, but I still get warnings about a missing .www.kiwix... directory when I load the file, which can happen even if the user never intended to actually use any of that package's functionality: those warnings should be delayed to when we actually call some of the package's functions. The main problem, tho, is the `request` dependency. There are two possible solutions to that: either we add `request` to GNU ELPA, or we rewrite the code so as not to use `request` (IIUC `request` is a reasonably thing wrapper above the `url` package, so it might not be too bad to do). The best course is probably to add `request` to GNU ELPA. Could you look into that, see how much work it would take to include `request` in GNU ELPA? Stefan diff --git a/kiwix.el b/kiwix.el index 5b765b5d3c..377772ee2e 100644 --- a/kiwix.el +++ b/kiwix.el @@ -1,5 +1,5 @@ -;;; kiwix.el --- Searching offline Wikipedia through Kiwix. -;;; -*- coding: utf-8 -*- +;;; kiwix.el --- Searching offline Wikipedia through Kiwix. -*- lexical-binding: t; -*- +;; -*- coding: utf-8 -*- ;; Copyright (C) 2019-2020 Free Software Foundation, Inc. @@ -9,7 +9,7 @@ ;; URL: https://github.com/stardiviner/kiwix.el ;; Created: 23th July 2016 ;; Version: 1.0.0 -;; Package-Requires: ((emacs "24.4") (cl-lib "0.5") (request "0.3.0")) +;; Package-Requires: ((emacs "24.4") (request "0.3.0")) ;; This file is part of GNU Emacs. @@ -28,13 +28,13 @@ ;;; Commentary: -;;; This currently only works for Linux, not tested for Mac OS X and Windows. +;; This currently only works for Linux, not tested for Mac OS X and Windows. -;;; Kiwix installation +;;;; Kiwix installation ;; ;; http://www.kiwix.org -;;; Config: +;;;; Config: ;; ;; (use-package kiwix ;; :ensure t @@ -45,7 +45,7 @@ ;; kiwix-server-port 8080 ;; kiwix-default-library "wikipedia_zh_all_2015-11.zim")) -;;; Usage: +;;;; Usage: ;; ;; 1. [M-x kiwix-launch-server] to launch Kiwix server. ;; 2. [M-x kiwix-at-point] to search the word under point or the region selected string. @@ -58,7 +58,7 @@ (require 'subr-x) (require 'thingatpt) (require 'json) -(if (featurep 'ivy) (require 'ivy)) +(if (featurep 'ivy) (require 'ivy)) ;FIXME: That's a no-op! (defgroup kiwix-mode nil "Kiwix customization options." @@ -67,19 +67,16 @@ (defcustom kiwix-server-use-docker nil "Using Docker container for kiwix-serve or not?" :type 'boolean - :safe #'booleanp - :group 'kiwix-mode) + :safe #'booleanp) (defcustom kiwix-server-port 8000 "Specify default kiwix-serve server port." :type 'number - :safe #'numberp - :group 'kiwix-mode) + :safe #'numberp) (defcustom kiwix-server-url (format "http://127.0.0.1:%s" kiwix-server-port) "Specify Kiwix server URL." - :type 'string - :group 'kiwix-mode) + :type 'string) (defcustom kiwix-server-command (cond @@ -90,44 +87,40 @@ ((string-equal system-type "windows-nt") (warn "You need to specify Windows Kiwix path. And send a PR to my repo."))) "Specify kiwix server command." - :type 'string - :group 'kiwix-mode) + :type 'string) (defun kiwix-dir-detect () "Detect Kiwix profile directory exist." - (let ((kiwix-dir (concat (getenv "HOME") "/.www.kiwix.org/kiwix"))) - (if (file-accessible-directory-p kiwix-dir) + (let ((kiwix-dir "~/.www.kiwix.org/kiwix")) + (if (file-directory-p kiwix-dir) kiwix-dir - (warn "ERROR: Kiwix profile directory \".www.kiwix.org/kiwix\" is not accessible.")))) + (warn "ERROR: Kiwix profile directory \"~/.www.kiwix.org/kiwix\" is not accessible.") + nil))) (defcustom kiwix-default-data-profile-name (when (kiwix-dir-detect) - (car (directory-files - (concat (getenv "HOME") "/.www.kiwix.org/kiwix") nil ".*\\.default"))) + (car (directory-files "~/.www.kiwix.org/kiwix" nil ".*\\.default"))) "Specify the default Kiwix data profile path." - :type 'string - :group 'kiwix-mode) + :type 'string) (defcustom kiwix-default-data-path (when (kiwix-dir-detect) - (concat (getenv "HOME") "/.www.kiwix.org/kiwix/" kiwix-default-data-profile-name)) + (expand-file-name kiwix-default-data-profile-name + "~/.www.kiwix.org/kiwix/")) "Specify the default Kiwix data path." :type 'string - :safe #'stringp - :group 'kiwix-mode) + :safe #'stringp) (defcustom kiwix-default-library-path (file-name-directory (concat kiwix-default-data-path "/data/library/library.xml")) "Kiwix libraries path." :type 'string - :safe #'stringp - :group 'kiwix-mode) + :safe #'stringp) (defcustom kiwix-default-completing-read 'ivy "Kiwix default completion frontend. Currently Ivy ('ivy) and Helm ('helm) both supported." :type 'symbol - :safe #'symbolp - :group 'kiwix-mode) + :safe #'symbolp) (defcustom kiwix-default-browser-function browse-url-browser-function "Set default browser for open kiwix query result URL." @@ -139,8 +132,7 @@ (const :tag "Google Chrome web browser" browse-url-chrome) (const :tag "Conkeror web browser" browse-url-conkeror) (const :tag "xwidget browser" xwidget-webkit-browse-url)) - :safe #'symbolp - :group 'kiwix-mode) + :safe #'symbolp) ;;;###autoload (defun kiwix--get-library-name (file) @@ -179,19 +171,16 @@ Like in function `kiwix-ajax-search-hints'.") (defcustom kiwix-default-library "wikipedia_en_all.zim" "The default kiwix library when library fragment in link not specified." :type 'string - :safe #'stringp - :group 'kiwix-mode) + :safe #'stringp) (defcustom kiwix-search-interactively t "`kiwix-at-point' search interactively." :type 'boolean - :safe #'booleanp - :group 'kiwix-mode) + :safe #'booleanp) (defcustom kiwix-mode-prefix nil "Specify kiwix-mode keybinding prefix before loading." - :type 'kbd - :group 'kiwix-mode) + :type 'kbd) ;; update kiwix server url and port (defun kiwix-server-url-update () @@ -258,7 +247,7 @@ Like in function `kiwix-ajax-search-hints'.") (when (string-equal (cdr error-thrown) "exited abnormally with code 7\n") (warn "kiwix.el failed to connect to host. exited abnormally with status code: 7.")))) :success (cl-function - (lambda (&key data &allow-other-keys) + (lambda (&key _data &allow-other-keys) ;FIXME: Why not `&rest _'? (setq kiwix-server-available? t))) :status-code '((404 . (lambda (&rest _) (message (format "Endpoint %s does not exist." url)))) (500 . (lambda (&rest _) (message (format "Error from %s." url)))))))) @@ -290,12 +279,12 @@ list and return a list result." (mapcar 'cdar data))))) ;;;###autoload -(defun kiwix-at-point (&optional interactively) +(defun kiwix-at-point () "Search for the symbol at point with `kiwix-query'. Or When prefix argument `INTERACTIVELY' specified, then prompt for query string and library interactively." - (interactive "P") + (interactive) (unless (kiwix-ping-server) (kiwix-launch-server)) (if kiwix-server-available? @@ -368,7 +357,6 @@ for query string and library interactively." :require 'kiwix-mode :init-value nil :lighter " Kiwix" - :group 'kiwix-mode :keymap kiwix-mode-map (if kiwix-mode (kiwix-mode-enable) (kiwix-mode-disable)))