Subject: [bug#57069] Tempel snippets

From: Nicolas Graves <[email-masked]>
Date: Tue, 09 Aug 2022 12:16:21 +0200

The first patch of this series introduces the equivalent of current
yasnippet templates, with the alternative package tempel.

I eventually chose to make a new folder in snippets dir, and to move
yasnippet files, hope it's OK.

It works quite well for me now, but can be improved:

- I selected completing-read for completion because I'm still learning
  emacs and didn't tackle completion-at-point for now. Would that be
  better?

- Nested snippets don't seem to work that well (e.g. expanding
  git-fetch... within the edition of an origin... expansion), I had
  quite a few bugs. Seems better to finish the current snippet before
  tackling a sub-snippet (for now at least).

- I couldn't match a small part of current yasnippet configuration,
  currently only the part in uri when url-fetch is chosen. Sent
  a "help/feature report" here https://github.com/minad/tempel/issues/65.

If this is possible, we could probably further factorize and integrate the
snippets logic, maybe to reach something like that for origin
expansion.

(origin...
 (let*
     ((method-list
       '(url-fetch
         url-fetch/tarbomb
         url-fetch/zipbomb
         cvs-fetch
         git-fetch
         hg-fetch
         svn-fetch
         bzr-fetch))
      (uri (cl-case method
             ('git-fetch '("(git-reference" n>
                           "(url " p ")" n>
                           "(commit " p "))"))
             ('svn-fetch '("(svn-reference" n>
                           "(url " p ")" n>
                           "(revision " p "))"))
             ('hg-fetch  '("(hg-reference" n>
                           "(url " p ")" n>
                           "(changeset " p "))"))
             ('cvs-fetch '("(cvs-reference" n>
                           "(root-directory " p ")" n>
                           "(module " p ")" n>
                           "(revision " p "))"))
             ('bzr-fetch '("(bzr-reference" n>
                           "(url " p ")" n>
                           "(revision " p "))"))
             (t              '("(string-append https://" p ".tar.gz)"))))
      (fname (cl-case method
               ('git-fetch '("(file-name (git-file-name name version))" n>))
               ('svn-fetch '("(file-name (string-append name \"-\" version \"-checkout\"))" n>))
               ('hg-fetch  '("(file-name (hg-file-name name version))" n>))
               ('cvs-fetch '("(file-name (string-append name \"-\" version \"-checkout\"))" n>))
               ('bzr-fetch '("(file-name (string-append name \"-\" version \"-checkout\"))" n>))
               (t              '("")))))
   "(origin" n>
   "(method \"" (p (completing-read "method:" method-list nil t)) "\")" n>
   "(uri " uri ")" n>
   fname
   "(sha256" n> "(base32 \"" p "\")))" n>))

The next patches are just new patches proposals, including :phases and
licenses. Also note that there were 3 or 4 missing build-systems in the
yasnippet template (might add them in a patch here).

-- 
Best regards,
Nicolas Graves