From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help,gmane.emacs.devel Subject: modularity, code for yourself and possibly others Date: Fri, 29 Mar 2019 01:42:30 +0100 Message-ID: <86wokiqznt.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="75436"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cc: emacs-devel@gnu.org To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Mar 29 01:48:05 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h9fgh-000JTu-Gm for geh-help-gnu-emacs@m.gmane.org; Fri, 29 Mar 2019 01:48:03 +0100 Original-Received: from localhost ([127.0.0.1]:44187 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9fgg-0007CW-Ew for geh-help-gnu-emacs@m.gmane.org; Thu, 28 Mar 2019 20:48:02 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:58963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9fbU-0002q9-3c for help-gnu-emacs@gnu.org; Thu, 28 Mar 2019 20:42:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h9fbS-0001Se-U5 for help-gnu-emacs@gnu.org; Thu, 28 Mar 2019 20:42:40 -0400 Original-Received: from [195.159.176.226] (port=56528 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h9fbS-0001Rz-J9 for help-gnu-emacs@gnu.org; Thu, 28 Mar 2019 20:42:38 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1h9fbR-000Dtb-0D for help-gnu-emacs@gnu.org; Fri, 29 Mar 2019 01:42:37 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Followup-To: gmane.emacs.help Mail-Copies-To: never Cancel-Lock: sha1:dGtSEK/MCLv1uKFeSMmKBoHjo+k= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:119774 gmane.emacs.devel:234809 Archived-At: N.B. This is not me posting code! I mean, obviously it is :) But it is not for the purpose of posting code! It is for the purpose of illustrating an issue and formulating a question (two questions). The example comes from the real situation, of course, but nonetheless. And as for this "silly explanation" (I didn't find a good English word for it, in Swedish we say "gardering" which `google-translate' [1], i.e. Google Translate, translates into "hedging", which I take is the literal translation of the word) - anyway as for this silly explanation, it is for display purposes ONLY :)) The least interesting part of the problem first: How do I remove all blank lines from a buffer? I.e. `delete-blank-lines' en masse? I wrote this: (defun delete-all-blank-lines () (interactive) (flush-lines "^[[:space:]]*$" (point-min) (point-max)) ) (defalias 'neat #'delete-all-blank-lines) It seems to work, but perhaps anyone can spot an error or do it even neater? OK, now for the more interesting problem! todo-did.el [3] has undergone some early expected bugs and ditto -fixes. One of them involved the use of the above function, "delete-all-blank-lines". But because that is a function of generic value and use, I have it in another file [2]. So now todo-did.el has to `require' that file. Oh, no! In todo-did.el, I put it like this: (require 'edit) ; http://user.it.uu.se/~embe8573/emacs-init/edit.el [...] (delete-all-blank-lines) ; http://user.it.uu.se/~embe8573/emacs-init/edit.el However that really won't help as in edit.el, I have (require 'tabs) (require 'sudo-user-path) (require 'window-new) And in those files... yes, by now you get the picture. So, if anyone but me ever would like to try todo-did.el, it'd be a heck of a job getting all those files. Well, not really, as they are all in one place and mentioned by name, that would be a very easy job! But absolutely not a job one can expect from someone else who just wants to try out a piece of new software! So how does one solve that? OK, here for a last "gardering". Some might say, "'delete-all-blank-lines' is just a one-liner. Why don't you just put it verbatim in todo-did.el?" Well, 1) it is a matter of principle that two wrongs don't make a right, and 2) I have so much Elisp already so if I didn't have it modularized it would be a total disaster for many reasons. One would be, whenever a bug is discovered I'd have to search the entire code [3] and alter every instance! So how should it be done? [1] Get from MELPA or https://github.com/atykhonov/google-translate [2] http://user.it.uu.se/~embe8573/emacs-init/edit.el [3] Actually I have a zsh snippet for that, line 51 @ http://user.it.uu.se/~embe8573/conf/.zsh/zsh-to-emacs - but I use that enough already thank you :) -- underground experts united http://user.it.uu.se/~embe8573