public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/eselect:master commit in: misc/, /
@ 2022-05-01 17:35 Ulrich Müller
  0 siblings, 0 replies; 7+ messages in thread
From: Ulrich Müller @ 2022-05-01 17:35 UTC (permalink / raw
  To: gentoo-commits

commit:     2052ab77d3856593ae6c41d305377058d22ed0d2
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sun May  1 17:15:38 2022 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Sun May  1 17:15:38 2022 +0000
URL:        https://gitweb.gentoo.org/proj/eselect.git/commit/?id=2052ab77

Drop XEmacs compatibility code in eselect-mode

* misc/eselect-mode.el (eselect-mode-before-save):
Call delete-trailing-whitespace which exists in XEmacs 21.5.

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 ChangeLog            | 2 ++
 misc/eselect-mode.el | 6 +-----
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 83b0289..4ef1610 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
 
 	* misc/eselect-mode.el (eselect-mode): For GNU Emacs, use
 	write-contents-functions instead of obsolete write-contents-hooks.
+	(eselect-mode-before-save): Call delete-trailing-whitespace which
+	exists in XEmacs 21.5.
 
 2022-01-08  Ulrich Müller  <ulm@gentoo.org>
 

diff --git a/misc/eselect-mode.el b/misc/eselect-mode.el
index 50e88d6..3bdac81 100644
--- a/misc/eselect-mode.el
+++ b/misc/eselect-mode.el
@@ -96,11 +96,7 @@
 ;;; Mode definitions.
 
 (defun eselect-mode-before-save ()
-  ;;(delete-trailing-whitespace)	; doesn't exist in XEmacs
-  (save-excursion
-    (goto-char (point-min))
-    (while (re-search-forward "[ \t]+$" nil t)
-      (delete-region (match-beginning 0) (point))))
+  (delete-trailing-whitespace)
   ;; return nil, otherwise the file is presumed to be written
   nil)
 


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/eselect:master commit in: misc/, /
@ 2023-06-12 16:24 Ulrich Müller
  0 siblings, 0 replies; 7+ messages in thread
From: Ulrich Müller @ 2023-06-12 16:24 UTC (permalink / raw
  To: gentoo-commits

commit:     4ebe3143212afa53ffc2f88156cc69a4f383375b
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 12 15:48:17 2023 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Mon Jun 12 15:48:17 2023 +0000
URL:        https://gitweb.gentoo.org/proj/eselect.git/commit/?id=4ebe3143

eselect-mode: Update copyright years before writing a file

* misc/eselect-mode.el (eselect, eselect-mode-fix-whitespace)
(eselect-mode-update-copyright): New custom group and variables.
(eselect-mode-copyright-regexp): New variable.
(eselect-mode-update-copyright): New function, mostly copied from
ebuild-mode-update-copyright in ebuild-mode.el.
(eselect-mode-before-save): Make fixing of whitespace conditional.
Update copyright years when customised to do so.

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 ChangeLog            | 10 ++++++++++
 misc/eselect-mode.el | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 87efe93..fd75fe3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-06-12  Ulrich Müller  <ulm@gentoo.org>
+
+	* misc/eselect-mode.el (eselect, eselect-mode-fix-whitespace)
+	(eselect-mode-update-copyright): New custom group and variables.
+	(eselect-mode-copyright-regexp): New variable.
+	(eselect-mode-update-copyright): New function, mostly copied from
+	ebuild-mode-update-copyright in ebuild-mode.el.
+	(eselect-mode-before-save): Make fixing of whitespace conditional.
+	Update copyright years when customised to do so.
+
 2023-06-07  Ulrich Müller  <ulm@gentoo.org>
 
 	* bin/eselect.in (PATH): Use printf instead of echo.

diff --git a/misc/eselect-mode.el b/misc/eselect-mode.el
index d7ea649..d2df858 100644
--- a/misc/eselect-mode.el
+++ b/misc/eselect-mode.el
@@ -1,6 +1,6 @@
 ;;; eselect-mode.el --- edit eselect files
 
-;; Copyright 2006-2022 Gentoo Authors
+;; Copyright 2006-2023 Gentoo Authors
 
 ;; Author: Matthew Kennedy <mkennedy@gentoo.org>
 ;;	Diego Pettenò <flameeyes@gentoo.org>
@@ -31,6 +31,26 @@
 (require 'sh-script)
 (require 'font-lock)
 
+;;; Variables.
+
+(defgroup eselect nil
+  "Major mode for Gentoo eselect modules."
+  :group 'languages)
+
+(defcustom eselect-mode-fix-whitespace t
+  "If non-nil, delete trailing whitespace before writing a file."
+  :type 'boolean
+  :group 'eselect)
+
+(defcustom eselect-mode-update-copyright t
+  "If non-nil, update copyright years before writing a file."
+  :type 'boolean
+  :group 'eselect)
+
+(defvar eselect-mode-copyright-regexp
+  "^#[ \t]*Copyright[ \t]+\\([1-9][0-9]+\\)\\(?:-\\([1-9][0-9]+\\)\\)?\
+[ \t]+\\(.*\\<Gentoo Authors\\>.*\\)")
+
 ;;; Font-lock.
 
 (defvar eselect-mode-keywords-warn
@@ -86,8 +106,37 @@
 
 ;;; Mode definitions.
 
+(defun eselect-mode-update-copyright ()
+  "Update the copyright notice in the file's header."
+  (save-excursion
+    (goto-char (point-min))
+    (let ((case-fold-search nil))
+      (when (re-search-forward eselect-mode-copyright-regexp 400 t)
+	(let* ((y1 (string-to-number (match-string 1)))
+	       (y2 (and (match-string 2)
+			(string-to-number (match-string 2))))
+	       (year (save-match-data (format-time-string "%Y" nil t)))
+	       (y (string-to-number year)))
+	  (if y2
+	      ;; Update range of years
+	      (if (or (> 2005 y1) (>= y1 y2) (> y2 y))
+		  (lwarn 'eselect :warning
+			 "Suspicious range of copyright years: %d-%d" y1 y2)
+		(if (/= y2 y)
+		    (replace-match year t t nil 2)))
+	    ;; Update single year and convert to range if necessary
+	    (if (or (> 2005 y1) (> y1 y))
+		(lwarn 'eselect :warning "Suspicious copyright year: %d" y1)
+	      (if (/= y1 y)
+		  (replace-match (concat "\\1-" year) t nil nil 1)))))))))
+
 (defun eselect-mode-before-save ()
-  (delete-trailing-whitespace)
+  (when eselect-mode-fix-whitespace
+    (delete-trailing-whitespace))
+  (when eselect-mode-update-copyright
+    (eselect-mode-update-copyright)
+    ;; call it only once per buffer
+    (set (make-local-variable 'eselect-mode-update-copyright) nil))
   ;; return nil, otherwise the file is presumed to be written
   nil)
 


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/eselect:master commit in: misc/, /
@ 2023-08-24 18:10 Ulrich Müller
  0 siblings, 0 replies; 7+ messages in thread
From: Ulrich Müller @ 2023-08-24 18:10 UTC (permalink / raw
  To: gentoo-commits

commit:     78b2c7b63e382bf3dd989b2f680ccdff356a39cc
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 24 17:31:49 2023 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Thu Aug 24 17:31:49 2023 +0000
URL:        https://gitweb.gentoo.org/proj/eselect.git/commit/?id=78b2c7b6

eselect-mode: Refer to sh-mode instead of shell-script-mode

* misc/eselect-mode.el (eselect-mode): Refer to sh-mode directly,
instead of shell-script-mode which is its alias.

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 ChangeLog            | 5 +++++
 misc/eselect-mode.el | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index e534492..670bbcf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-08-24  Ulrich Müller  <ulm@gentoo.org>
+
+	* misc/eselect-mode.el (eselect-mode): Refer to sh-mode directly,
+	instead of shell-script-mode which is its alias.
+
 2023-08-22  Ulrich Müller  <ulm@gentoo.org>
 
 	* doc/developer-guide.txt: Update documentation for "has".

diff --git a/misc/eselect-mode.el b/misc/eselect-mode.el
index bfcf494..57791f8 100644
--- a/misc/eselect-mode.el
+++ b/misc/eselect-mode.el
@@ -141,7 +141,7 @@
   nil)
 
 ;;;###autoload
-(define-derived-mode eselect-mode shell-script-mode "Eselect"
+(define-derived-mode eselect-mode sh-mode "Eselect"
   "Major mode for .eselect files."
   (add-hook 'write-contents-functions 'eselect-mode-before-save t t)
   (sh-set-shell "bash")


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/eselect:master commit in: misc/, /
@ 2023-08-25 15:50 Ulrich Müller
  0 siblings, 0 replies; 7+ messages in thread
From: Ulrich Müller @ 2023-08-25 15:50 UTC (permalink / raw
  To: gentoo-commits

commit:     e8d1843145399daeee83fb6793074bf80b06cad3
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 24 21:35:38 2023 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Fri Aug 25 08:39:59 2023 +0000
URL:        https://gitweb.gentoo.org/proj/eselect.git/commit/?id=e8d18431

eselect-mode: Enable lexical binding

* misc/eselect-mode.el: Enable lexical binding.

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 ChangeLog            | 2 ++
 misc/eselect-mode.el | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 670bbcf..f9ee3f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2023-08-24  Ulrich Müller  <ulm@gentoo.org>
 
+	* misc/eselect-mode.el: Enable lexical binding.
+
 	* misc/eselect-mode.el (eselect-mode): Refer to sh-mode directly,
 	instead of shell-script-mode which is its alias.
 

diff --git a/misc/eselect-mode.el b/misc/eselect-mode.el
index 57791f8..e59c90c 100644
--- a/misc/eselect-mode.el
+++ b/misc/eselect-mode.el
@@ -1,4 +1,4 @@
-;;; eselect-mode.el --- edit eselect files
+;;; eselect-mode.el --- edit eselect files  -*-lexical-binding:t-*-
 
 ;; Copyright 2006-2023 Gentoo Authors
 


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/eselect:master commit in: misc/, /
@ 2023-10-06  7:46 Ulrich Müller
  0 siblings, 0 replies; 7+ messages in thread
From: Ulrich Müller @ 2023-10-06  7:46 UTC (permalink / raw
  To: gentoo-commits

commit:     2f9084ac529bcd514a3546a9d7f9a376f1c4a5d5
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Fri Oct  6 07:36:28 2023 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Fri Oct  6 07:36:28 2023 +0000
URL:        https://gitweb.gentoo.org/proj/eselect.git/commit/?id=2f9084ac

eselect-mode: Use named function in hook variable

* misc/eselect-mode.el (eselect-mode-add-font-lock): New function.
(eselect-mode-hook): Add it, instead of an anonymous function.

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 ChangeLog            | 5 +++++
 misc/eselect-mode.el | 7 ++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 65307ec..13bbc97 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-10-06  Ulrich Müller  <ulm@gentoo.org>
+
+	* misc/eselect-mode.el (eselect-mode-add-font-lock): New function.
+	(eselect-mode-hook): Add it, instead of an anonymous function.
+
 2023-09-13  Ulrich Müller  <ulm@gentoo.org>
 
 	* configure.ac: Update version to 1.4.27.

diff --git a/misc/eselect-mode.el b/misc/eselect-mode.el
index e59c90c..06843df 100644
--- a/misc/eselect-mode.el
+++ b/misc/eselect-mode.el
@@ -148,10 +148,11 @@
   (setq tab-width 4)
   (setq indent-tabs-mode t))
 
-(add-hook 'eselect-mode-hook
-	  (lambda () (font-lock-add-keywords
-		      nil eselect-mode-font-lock-keywords)))
+(defun eselect-mode-add-font-lock ()
+  "Add `eselect-mode' font-lock keywords for the current buffer."
+  (font-lock-add-keywords nil eselect-mode-font-lock-keywords))
 
+(add-hook 'eselect-mode-hook 'eselect-mode-add-font-lock)
 
 ;;;###autoload
 (add-to-list 'auto-mode-alist '("\\.eselect\\'" . eselect-mode))


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/eselect:master commit in: misc/, /
@ 2023-10-21  8:50 Ulrich Müller
  0 siblings, 0 replies; 7+ messages in thread
From: Ulrich Müller @ 2023-10-21  8:50 UTC (permalink / raw
  To: gentoo-commits

commit:     aa4697a70dec32ad6e7e371899968afc7fe338e6
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Fri Oct  6 07:38:41 2023 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Fri Oct  6 07:38:41 2023 +0000
URL:        https://gitweb.gentoo.org/proj/eselect.git/commit/?id=aa4697a7

eselect-mode: Use #' for quoting of function names

* misc/eselect-mode.el (eselect-mode, eselect-mode-hook):
Sharp-quote the function names.

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 ChangeLog            | 3 +++
 misc/eselect-mode.el | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 13bbc97..c0fe120 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2023-10-06  Ulrich Müller  <ulm@gentoo.org>
 
+	* misc/eselect-mode.el (eselect-mode, eselect-mode-hook):
+	Sharp-quote the function names.
+
 	* misc/eselect-mode.el (eselect-mode-add-font-lock): New function.
 	(eselect-mode-hook): Add it, instead of an anonymous function.
 

diff --git a/misc/eselect-mode.el b/misc/eselect-mode.el
index 06843df..d6fc68e 100644
--- a/misc/eselect-mode.el
+++ b/misc/eselect-mode.el
@@ -143,7 +143,7 @@
 ;;;###autoload
 (define-derived-mode eselect-mode sh-mode "Eselect"
   "Major mode for .eselect files."
-  (add-hook 'write-contents-functions 'eselect-mode-before-save t t)
+  (add-hook 'write-contents-functions #'eselect-mode-before-save t t)
   (sh-set-shell "bash")
   (setq tab-width 4)
   (setq indent-tabs-mode t))
@@ -152,7 +152,7 @@
   "Add `eselect-mode' font-lock keywords for the current buffer."
   (font-lock-add-keywords nil eselect-mode-font-lock-keywords))
 
-(add-hook 'eselect-mode-hook 'eselect-mode-add-font-lock)
+(add-hook 'eselect-mode-hook #'eselect-mode-add-font-lock)
 
 ;;;###autoload
 (add-to-list 'auto-mode-alist '("\\.eselect\\'" . eselect-mode))


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/eselect:master commit in: misc/, /
@ 2023-11-05 17:39 Ulrich Müller
  0 siblings, 0 replies; 7+ messages in thread
From: Ulrich Müller @ 2023-11-05 17:39 UTC (permalink / raw
  To: gentoo-commits

commit:     88eb5c77a9aa08a1e69bc41aea73c78e8e7a26f4
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sun Nov  5 17:31:24 2023 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Sun Nov  5 17:31:24 2023 +0000
URL:        https://gitweb.gentoo.org/proj/eselect.git/commit/?id=88eb5c77

eselect-mode: Doc fix

* misc/eselect-mode.el: Doc fix.

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 ChangeLog            | 4 ++++
 misc/eselect-mode.el | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index c0fe120..da11122 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2023-11-05  Ulrich Müller  <ulm@gentoo.org>
+
+	* misc/eselect-mode.el: Doc fix.
+
 2023-10-06  Ulrich Müller  <ulm@gentoo.org>
 
 	* misc/eselect-mode.el (eselect-mode, eselect-mode-hook):

diff --git a/misc/eselect-mode.el b/misc/eselect-mode.el
index d6fc68e..6ffa88f 100644
--- a/misc/eselect-mode.el
+++ b/misc/eselect-mode.el
@@ -131,6 +131,8 @@
 		  (replace-match (concat "\\1-" year) t nil nil 1)))))))))
 
 (defun eselect-mode-before-save ()
+  "Function to be called before saving a buffer.
+This will be added to the `write-contents-functions' hook."
   (when eselect-mode-fix-whitespace
     (delete-trailing-whitespace))
   (when eselect-mode-update-copyright


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-11-05 17:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-21  8:50 [gentoo-commits] proj/eselect:master commit in: misc/, / Ulrich Müller
  -- strict thread matches above, loose matches on Subject: below --
2023-11-05 17:39 Ulrich Müller
2023-10-06  7:46 Ulrich Müller
2023-08-25 15:50 Ulrich Müller
2023-08-24 18:10 Ulrich Müller
2023-06-12 16:24 Ulrich Müller
2022-05-01 17:35 Ulrich Müller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox