help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

modularity, code for yourself and possibly others


From: Emanuel Berg
Subject: modularity, code for yourself and possibly others
Date: Fri, 29 Mar 2019 01:42:30 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]