unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Emanuel Berg <moasenwood@zoho.eu>
To: help-gnu-emacs@gnu.org
Cc: emacs-devel@gnu.org
Subject: modularity, code for yourself and possibly others
Date: Fri, 29 Mar 2019 01:42:30 +0100	[thread overview]
Message-ID: <86wokiqznt.fsf@zoho.eu> (raw)

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




             reply	other threads:[~2019-03-29  0:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-29  0:42 Emanuel Berg [this message]
2019-03-29 10:43 ` modularity, code for yourself and possibly others Tadeus Prastowo
2019-04-01 22:22   ` Emanuel Berg
2019-04-02  9:42     ` Tadeus Prastowo
2019-04-04  3:20       ` Emanuel Berg
2019-04-04  8:10         ` Tadeus Prastowo
2019-04-04 22:38           ` Richard Stallman
2019-04-05  3:16             ` Emanuel Berg
2019-04-05 22:31               ` Richard Stallman
2019-04-05  9:57             ` Tadeus Prastowo
2019-04-05 22:33               ` Richard Stallman
2019-04-05 22:48                 ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86wokiqznt.fsf@zoho.eu \
    --to=moasenwood@zoho.eu \
    --cc=emacs-devel@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).