diff options
author | Ulrich Müller <ulm@gentoo.org> | 2007-11-17 20:09:43 +0000 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2007-11-17 20:09:43 +0000 |
commit | 63141b14fa28e79bbdb597f772e3c08b7ff8f98a (patch) | |
tree | 72faf4328ff7c10e7fbfdc3cd13bc765d980f73f | |
parent | Bug fix, use ebuild-commands-list instead of alist. (diff) | |
download | ebuild-mode-63141b14fa28e79bbdb597f772e3c08b7ff8f98a.tar.gz ebuild-mode-63141b14fa28e79bbdb597f772e3c08b7ff8f98a.tar.bz2 ebuild-mode-63141b14fa28e79bbdb597f772e3c08b7ff8f98a.zip |
User interface for keyword handling rewritten.
svn path=/emacs-extra/gentoo-syntax/; revision=750
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | gentoo-syntax.el | 95 |
2 files changed, 61 insertions, 40 deletions
@@ -2,6 +2,12 @@ * gentoo-syntax.el (ebuild-run-command): Bug fix, use ebuild-commands-list instead of alist. + (ebuild-mode-keyword, ebuild-mode-ekeyword-complete) + (ebuild-mode-ekeyword): New functions, rewritten user interface. + (ebuild-mode-map): Keybindings adapted accordingly. + (ebuild-mode-keyword-stable, ebuild-mode-keyword-unstable) + (ebuild-mode-keyword-mask, ebuild-mode-keyword-drop): + Functions removed. 2007-11-11 Ulrich Mueller <ulm@gentoo.org> diff --git a/gentoo-syntax.el b/gentoo-syntax.el index 10881bd..4653c5e 100644 --- a/gentoo-syntax.el +++ b/gentoo-syntax.el @@ -742,53 +742,68 @@ A formfeed is not considered whitespace by this function." (ebuild-mode-put-keywords (ebuild-mode-sort-keywords keywords)))) -(defun ebuild-mode-keyword-stable (arch) - "Set stable keyword for ARCH." +(defun ebuild-mode-keyword (arch mode) + "Keyword manipulation." (interactive (list - (completing-read "Stable arch: " - (mapcar 'list (cons "all" ebuild-mode-arch-stable-list)) - nil t))) - (ebuild-mode-modify-keywords `((,arch . "")))) - -(defun ebuild-mode-keyword-unstable (arch) - "Set unstable keyword for ARCH." - (interactive - (list - (completing-read "Unstable arch: " - (mapcar 'list (cons "all" ebuild-mode-arch-list)) - nil t))) - (ebuild-mode-modify-keywords `((,arch . "~")))) - -(defun ebuild-mode-keyword-mask (arch) - "Mask keyword for ARCH." - (interactive - (list - (completing-read "Mask arch: " - (mapcar 'list (append '("all" "*") - ebuild-mode-arch-list)) - nil t))) - (ebuild-mode-modify-keywords `((,arch . "-")))) - -(defun ebuild-mode-keyword-drop (arch) - "Drop keyword for ARCH." - (interactive - (list - (completing-read "Drop arch: " - (mapcar 'list (append '("all" "*") - ebuild-mode-arch-list)) - nil t))) - (ebuild-mode-modify-keywords `((,arch . nil)))) + (completing-read "Architecture: " + (mapcar 'list + (append '("all" "*") ebuild-mode-arch-list)) + nil t) + (let ((compl-alist + '(("unstable" . "~") + ("stable" . "") + ("mask" . "-") + ("drop" . nil)))) + (cdr (assoc (completing-read "Action: " compl-alist + nil t nil nil "unstable") + compl-alist))))) + (ebuild-mode-modify-keywords (list (cons arch mode)))) + +(defun ebuild-mode-ekeyword-complete (s predicate mode) + (string-match "^\\(.*[[:space:]]\\)?\\(.*\\)$" s) + (let* ((s1 (match-string 1 s)) + (s2 (match-string 2 s)) + (c2 (funcall + (cond ((null mode) 'try-completion) + ((eq mode t) 'all-completions) + ((eq mode 'lambda) 'test-completion)) + s2 + (mapcar 'list + (if (string-equal s2 "") + '("" "~" "-" "^") + (string-match "^\\([-^~]?\\)" s2) + (mapcar + (lambda (x) (concat (match-string 1 s2) x " ")) + (cond ((equal (match-string 1 s2) "") + (cons "all" ebuild-mode-arch-stable-list)) + ((equal (match-string 1 s2) "~") + (cons "all" ebuild-mode-arch-list)) + (t + (append '("all" "*") + ebuild-mode-arch-list)))))) + predicate))) + (if (stringp c2) (concat s1 c2) c2))) + +(defun ebuild-mode-ekeyword (keywords) + "Keyword manipulation. Accepts the same input format as ekeyword." + (interactive + (list (completing-read "Keywords: " 'ebuild-mode-ekeyword-complete))) + (ebuild-mode-modify-keywords + (mapcar (lambda (s) + (string-match "^\\([-^~]?\\)\\(.*\\)" s) + (cons (match-string 2 s) + (and (not (equal (match-string 1 s) "^")) + (match-string 1 s)))) + (split-string keywords)))) ;;; Keybindings. (define-key ebuild-mode-map "\C-c\C-e" 'ebuild-run-command) -;; The following four keybindings are preliminary and may change. -(define-key ebuild-mode-map "\C-c\C-s" 'ebuild-mode-keyword-stable) -(define-key ebuild-mode-map "\C-c\C-u" 'ebuild-mode-keyword-unstable) -(define-key ebuild-mode-map "\C-c\C-m" 'ebuild-mode-keyword-mask) -(define-key ebuild-mode-map "\C-c\C-d" 'ebuild-mode-keyword-drop) +;; The following two keybindings are preliminary and may change. +(define-key ebuild-mode-map "\C-c\C-k" 'ebuild-mode-keyword) +(define-key ebuild-mode-map "\C-c\C-a" 'ebuild-mode-ekeyword) (and (< emacs-major-version 22) ;; make TAB key work |