From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Easy configuration of a site-lisp directory Date: Sun, 08 Aug 2021 15:40:57 +0000 Message-ID: <87y29cj65y.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11010"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Aug 08 17:42:07 2021 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 1mCkwA-0002fD-T2 for ged-emacs-devel@m.gmane-mx.org; Sun, 08 Aug 2021 17:42:06 +0200 Original-Received: from localhost ([::1]:50088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mCkw9-0002hv-09 for ged-emacs-devel@m.gmane-mx.org; Sun, 08 Aug 2021 11:42:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCkvC-0001zQ-Gw for emacs-devel@gnu.org; Sun, 08 Aug 2021 11:41:06 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:48613) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCkv7-0008Nc-Ta for emacs-devel@gnu.org; Sun, 08 Aug 2021 11:41:06 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id A9582240029 for ; Sun, 8 Aug 2021 17:40:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1628437258; bh=9p4otzrYddBj8X6Sd+lBvfR/Zau54wjUMx0Zlabim4U=; h=From:To:Subject:Date:From; b=fhyAvKCbrSsEyhdHdDR5D04+pfN80UBMg1HXNgUDFRddN51Cwzmk0bnYxPJ6LfgW1 Iqu75n/kaRLwrvMHis2l389+OKtZvakf+un3z1kRnuB4Ut24hu5b0nIb71HUR2xr8V TKGax8H5eqwbhafanaiMEBgWtzFZ5QQRs4VKBL1oPo5RIiUI0u2HDOG39GDUoJUMka M9g3vMotKPDckDmIc7mK9zzs2a8tY8rcaBAp/3W/yjTyX3+2258mzfaBTZPEWaBNuP kKaVpkA8EcDH8EV9wcy3pMbEVl/dZd1HZklmxHaEToMSiCbgz2Mp2QaGpKwMe3zOu+ 9h4a5Wh/uunLw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4GjNj56vgHz9rxL for ; Sun, 8 Aug 2021 17:40:57 +0200 (CEST) Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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:272205 Archived-At: --=-=-= Content-Type: text/plain Hi, I have been using something along these lines for a while now, and wanted to suggest adding this to Emacs/ELPA: --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=site-lisp.el Content-Transfer-Encoding: quoted-printable ;;; site-lisp.el --- Manage site-lisp directories -*- lexical-binding: t; = -*- ;; Copyright (C) 2021 Philip Kaludercic ;; Author: Philip Kaludercic ;; Keywords: lisp, local ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program 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 General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; The following code manages site-local Lisp code, that might not be ;; part of a package. For regular use, create a "site-lisp" directory ;; next to "init.el", and create a subdirectory for every program you ;; wish to use. ;;; Code: (defgroup site-lisp () "Manage site-lisp directories." :group 'lisp) (defcustom site-lisp-autoload-file "autoload.el" "Name of file to store autoload forms in." :type 'string :version "28.1") (defun site-lisp-prepare (dir) "Byte-compile, prepare autoloads and note each directory in DIR." (interactive "DPrepare: ") (let* ((backup-inhibited t) (autoload-file (expand-file-name site-lisp-autoload-file dir))) (dolist (dir (directory-files dir t "^[^.]")) (when (file-directory-p dir) (add-to-list 'load-path dir) (make-directory-autoloads dir autoload-file) (byte-recompile-directory dir))) (add-to-list 'load-path dir) (load autoload-file nil t))) (defun site-lisp-unprepare (dir) "Remove every directory in DIR from `load-path'." (interactive "DUnprepare: ") (dolist (dir (directory-files dir t "^[^.]")) ;; TODO: reverse everything that might have been autoloaded. (when (cons dir (file-directory-p dir)) (setq load-path (remove dir load-path))))) ;;;###autoload (defcustom site-lisp-directory (locate-user-emacs-file "site-lisp") "Directory use for site-local Lisp code. If this directory doesn't exist, nothing is done." :set (lambda (var val) (when (and (boundp 'site-lisp-directory) (file-directory-p site-lisp-directory)) (site-lisp-unprepare site-lisp-directory)) (when (file-directory-p val) (site-lisp-prepare val)) (set var val)) :type 'directory :version "28.1") ;;;###autoload (defun site-lisp-reload () "Reload the contents of `site-lisp-directory'." (interactive) (site-lisp-prepare site-lisp-directory)) (provide 'site-lisp) ;;; site-lisp.el ends here --=-=-= Content-Type: text/plain The fundamental idea is to have an easy-to-use ~/.emacs.d/site-lisp/ directory where a user can clone any repository or create their own, without having to manually add these to load-path, generate autoloads or byte compile. All my personal packages are managed this way without any issues that I have noticed. My hope is that something like this would ease working on and contributing to packages. The above attachment is a stand-alone file, while my version is just a blob at the beginning of my init.el. If there is any interest, it might also be possible to add it to an existing file, but I was not sure where it would fit in best. -- Philip K. --=-=-=--