From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Emanuel Berg via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: Re: good enough for MELPA work? Date: Wed, 26 Feb 2020 10:16:42 +0100 Message-ID: <871rqhg139.fsf@ebih.ebihd> References: <87imjtg660.fsf@ebih.ebihd> Reply-To: Emanuel Berg Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="75603"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:rzuYTzPy2PpXZa/B8j+5Q4J02t8= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 26 10:20:20 2020 Return-path: Envelope-to: geh-help-gnu-emacs@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 1j6src-000Jam-Em for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 26 Feb 2020 10:20:20 +0100 Original-Received: from localhost ([::1]:40792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6srb-0004Gl-En for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 26 Feb 2020 04:20:19 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37640) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6soI-0007Va-La for help-gnu-emacs@gnu.org; Wed, 26 Feb 2020 04:16:56 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6soE-00044l-Kt for help-gnu-emacs@gnu.org; Wed, 26 Feb 2020 04:16:54 -0500 Original-Received: from ciao.gmane.io ([159.69.161.202]:36484) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j6soE-0003zW-Dh for help-gnu-emacs@gnu.org; Wed, 26 Feb 2020 04:16:50 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1j6soD-000FPo-2H for help-gnu-emacs@gnu.org; Wed, 26 Feb 2020 10:16:49 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Mail-Copies-To: never X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 159.69.161.202 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:122478 Archived-At: > It (checkdoc) still complains about the first > line, but that is OK, right? So that is > a bug, if indeed alright. Here what it says: *** isbn-verify.el: checkdoc-current-buffer V 0.6.1 isbn-verify.el:0: The first line should be of the form: ";;; package --- Summary" All other warnings are now gone, I added some dorky documentation because I can't handle programs warning me about stuff. It comes with the territory. ;;; isbn-verify - Verify ISBN-10 and ISBN-13 -*- lexical-binding: t -*- ;; ;;; Commentary: ;; ;; This Elisp package provides functions to ;; verify ISBNs by computing their check ;; digits. The package can be found here: ;; ;; ;; The package was last modified by Emanuel Berg ;; 2020-02-26. Mail feedback to ;; or talk to me at IRC, I'm incal on freenode. ;; ;; For more info on ISBNs and how the check ;; digits are computed, see: ;; ;; ;; To see how it works, try ;; `check-isbn-at-point' on these two Biblatex ;; entries, the first one with ISBN-10, the ;; second with ISBN-13. Place point at the ;; beginning of the ISBN, then do M-x ciap RET ;; ;; @book{russia-and-the-arms-trade, ;; author = {Ian Anthony}, ;; isbn = {0-19-829278-3}, ;; publisher = {Oxford}, ;; title = {Russia and the Arms Trade}, ;; year = 1998 ;; } ;; ;; @book{baa-lo-4, ;; author = {Yukito Kishiro}, ;; isbn = {978-1-61262-294-1}, ;; publisher = {Kodansha}, ;; title = {Battle Angel Alita: The Last Order 4}, ;; year = {2014 (2011)} ;; } ;; ;; Or, with Lisp: ;; ;; (checksum-isbn-10 "0-19-829576-6") ; 6 ;; (checksum-isbn-13 "978-1-61262-294-1") ; 1 ;; ;;; Code: (require 'cl-lib) (defun digits-only-string (str) "Evaluate into a version of STR, with all non-digits removed." (replace-regexp-in-string "[^0-9]" "" str) ) (defun char-to-int (c) "Convert a char C into the digit it displays, e.g., (char-to-int ?9) ; 9" (- c ?0)) (defun string-to-integer-list (str) "Make an integer list from a string STR. All non-digits are dropped." (let*((digits-only (digits-only-string str)) (chars (string-to-list digits-only)) (ints (cl-map 'list (lambda (c) (char-to-int c)) chars) )) ints) ) (defun check-isbn-at-point () "Compute and display the check digit from the ISBN at point. See \\[checksum-isbn-10] and \\[checksum-isbn-13] for Lisp work." (interactive) (let*((isbn-string (thing-at-point 'symbol t)) (digits-only (digits-only-string isbn-string)) (num-digits (length digits-only)) (check-digit (if (> num-digits 10) (checksum-isbn-13 digits-only) (checksum-isbn-10 digits-only) ))) (message "check digit: %s" check-digit) )) (defalias 'ciap #'check-isbn-at-point) (defun checksum-isbn-13 (isbn) "Compute the checksum for ISBN which should be ISBN-13, i.e. consist of 13 digits. Because the last digit, number 13, is the checksum, actually only 12 digits, in the form of a string, is needed. Hyphens/dashes can be included or omitted. Also see \\[checksum-isbn-10]. For interactive work, see \\[check-isbn-at-point]." (let*((isbn-ints (string-to-integer-list isbn)) (sum 0)) (cl-loop for e in isbn-ints for i from 0 to 11 do (progn (message "%d" i) (cl-incf sum (* e (or (and (zerop (mod i 2)) 1) 3))) ) ) (let ((checksum (- 10 (mod sum 10)))) (if (= 10 checksum) 0 checksum) ))) (defun checksum-isbn-10 (isbn) "Compute the checksum for ISBN which should be ISBN-10, i.e. consist of 10 digits. Because the last digit, number 10, is the checksum, actually only 9 digits, in the form of a string, is needed. Hyphens/dashes can be included or omitted. Also see \\[checksum-isbn-13]. For interactive work, see \\[check-isbn-at-point]." (let*((isbn-ints (string-to-integer-list isbn)) (sum 0) ) (cl-loop for e in isbn-ints for i downfrom 10 to 2 do (cl-incf sum (* e i)) ) (let ((checksum (mod (- 11 (mod sum 11)) 11))) (if (= 10 checksum) "X" checksum) ))) ;; 10 ISBN-10 tests: ;; ;; (checksum-isbn-10 "0-201-53992-6") ; 6 ;; (checksum-isbn-10 "0312168144") ; 4 ;; (checksum-isbn-10 "1-4012-0622-0") ; 0 ;; (checksum-isbn-10 "1616558717") ; 7 ;; (checksum-isbn-10 "91-510-6483-9") ; 9 ;; (checksum-isbn-10 "91-7054-940-0") ; 0 ;; (checksum-isbn-10 "91-7089-710-7") ; 7 ;; (checksum-isbn-10 "91-85668-01-X") ; X ;; (checksum-isbn-10 "91-88930-23-8") ; 8 ;; (checksum-isbn-10 "9177988515") ; 5 ;; 13 ISBN-13 tests: ;; ;; (checksum-isbn-13 "91-518-4657-8") ; 8 ;; (checksum-isbn-13 "978-1-63236-616-0") ; 0 ;; (checksum-isbn-13 "978-91-0-012814-2") ; 2 ;; (checksum-isbn-13 "978-91-29-59023-4") ; 4 ;; (checksum-isbn-13 "978-91-7037-681-8") ; 8 ;; (checksum-isbn-13 "978-91-7515-205-9") ; 9 ;; (checksum-isbn-13 "978-91-7515-317-9") ; 9 ;; (checksum-isbn-13 "978-91-86936-31-0") ; 0 ;; (checksum-isbn-13 "978-91-87861-54-3") ; 3 ;; (checksum-isbn-13 "978-91-87861-67-3") ; 3 ;; (checksum-isbn-13 "978-91-87861-99-4") ; 4 ;; (checksum-isbn-13 "9780062802187") ; 7 ;; (checksum-isbn-13 "9789188805034") ; 4 (provide 'isbn-verify) ;;; isbn-verify.el ends here -- underground experts united http://user.it.uu.se/~embe8573 https://dataswamp.org/~incal