commit:     f642f71894e5cc98063083713606b1655d2e8434
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sat Mar  4 22:03:40 2017 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Sat Mar  4 22:03:40 2017 +0000
URL:        https://gitweb.gentoo.org/proj/emacs-tools.git/commit/?id=f642f718

Default to most recent EAPI in ebuild skeleton.

* ebuild-mode.el (ebuild-mode-eapi-list): New custom variable.
(ebuild-mode-insert-skeleton): Use it in a completing-read.

 ChangeLog      |  3 +++
 ebuild-mode.el | 15 ++++++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 63838a4..845283e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2017-03-04  Ulrich Müller  <[email protected]>
 
+       * ebuild-mode.el (ebuild-mode-eapi-list): New custom variable.
+       (ebuild-mode-insert-skeleton): Use it in a completing-read.
+
        * ebuild-mode.el (ebuild-mode-protocols-homepage)
        (ebuild-mode-protocols-src_uri): New variables.
        (ebuild-mode-insert-skeleton): Add https:// to completions

diff --git a/ebuild-mode.el b/ebuild-mode.el
index 3e00080..7b927e6 100644
--- a/ebuild-mode.el
+++ b/ebuild-mode.el
@@ -69,6 +69,13 @@ A formfeed is not considered whitespace by this function."
   :type 'string
   :group 'ebuild-mode)
 
+(defcustom ebuild-mode-eapi-list
+  '("5" "6")
+  "List of supported EAPIs.
+The most recent EAPI must be listed last."
+  :type '(repeat string)
+  :group 'ebuild-mode)
+
 (defcustom ebuild-mode-fix-whitespace t
   "If non-nil, fix whitespace before writing a file.
 Namely, delete trailing whitespace and tabify whitespace at beginning
@@ -465,10 +472,12 @@ and `all-completions' for details."
    "# Copyright 1999-" (format-time-string "%Y") " Gentoo Foundation\n"
    "# Distributed under the terms of the GNU General Public License v2\n"
    "\n"
-   ;; EAPI
    "EAPI="
-   (skeleton-read "EAPI: ")
-   & "\n\n" | -5
+   (completing-read
+    "EAPI: " (mapcar 'list ebuild-mode-eapi-list)
+    nil nil (car (last ebuild-mode-eapi-list))) ; default to most recent EAPI
+   "\n"
+   "\n"
    ;; inherited eclasses
    "inherit "
    ((completing-read "Eclass (null string to terminate): "

Reply via email to