debian-changelog-mode.el 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. (defvar debian-changelog-urgencies
  2. '((?l."low") (?m."medium") (?h."HIGH"))
  3. "alist of keystrokes vs. urgency values for debian-changelog-urgency \\[debian-changelog-urgency].")
  4. (defvar debian-changelog-distributions
  5. '((?s."stable") (?u."unstable") (?c."contrib") (?n."non-free") (?e."experimental"))
  6. "alist of keystrokes vs. distribution values for debian-changelog-distribution \\[debian-changelog-distribution].")
  7. (defun debian-changelog-headervalue (arg re alist)
  8. (let (a b v k
  9. (lineend (save-excursion (end-of-line) (point))))
  10. (save-excursion
  11. (goto-char (point-min))
  12. (re-search-forward re lineend)
  13. (setq a (match-beginning 1)
  14. b (match-end 1))
  15. (goto-char a)
  16. (if arg nil
  17. (message (mapconcat
  18. (function (lambda (x) (format "%c:%s" (car x) (cdr x))))
  19. alist " "))
  20. (while (not v)
  21. (setq k (read-char))
  22. (setq v (assoc k alist))))
  23. (delete-region a b)
  24. (if arg nil (insert (cdr v))))
  25. (if arg (goto-char a))))
  26. (defun debian-changelog-distribution (arg)
  27. "Without argument, prompt for a key for a new distribution value (using
  28. debian-changelog-distributions). With argument, delete the current distribution
  29. and position the cursor to type a new one."
  30. (interactive "P")
  31. (debian-changelog-headervalue
  32. arg
  33. ") \\(.*\\)\\;"
  34. debian-changelog-distributions))
  35. (defun debian-changelog-urgency (arg)
  36. "Without argument, prompt for a key for a new urgency value (using
  37. debian-changelog-urgencies). With argument, delete the current urgency
  38. and position the cursor to type a new one."
  39. (interactive "P")
  40. (debian-changelog-headervalue
  41. arg
  42. "\\;[^\n]* urgency=\\(\\sw+\\)"
  43. debian-changelog-urgencies))