Subject: bug#77138: closed (Re: bug#77138: [PATCH v5] Add major mode for highlighting .npmrc files)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 29 Mar 2025 10:24:02 +0000

Your bug report

#77138: [PATCH] Add major mode for highlighting .npmrc files

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
77138: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=77138
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#77138: [PATCH v5] Add major mode for highlighting .npmrc files
From: Eli Zaretskii <[email-masked]>
To: Konstantin Kharlamov <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Sat, 29 Mar 2025 13:23:15 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Konstantin Kharlamov <[email-masked]>
> Cc: [email-masked], [email-masked]
> Date: Mon, 24 Mar 2025 11:16:28 +0300
> 
> v5 attached.
> 
> New change: the in files alist the dot excluded from npmrc naming, i.e.
> "\\.npmrc\\'" is replaced to "npmrc\\'".
> 
> Reason: even though npmrc are typically starting with a dot, but the
> official docs¹ mention there may be system-wide files without it, like
> `/etc/npmrc`.
> 
> 1: https://docs.npmjs.com/cli/v11/configuring-npm/npmrc

Thanks, installed on the master branch, and closing the bug.

Subject: [PATCH] Add major mode for highlighting .npmrc files
From: Konstantin Kharlamov <[email-masked]>
To: [email-masked]
Date: Thu, 20 Mar 2025 19:26:03 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

".npmrc" are configuration files used by "npm", which in turn is a
widely used package manager in web-development setting (javascript,
typescript, etc).

I don't have much expertise in NPM field, but judging by the official
documentation¹ it's basically ini-style `key = value`, but with two
comment styles (semicolon and hash sign).

Easily implementable by deriving from conf-mode and adding the comment
styles.

Patch is attached.

1: https://docs.npmjs.com/cli/v11/configuring-npm/npmrc
From fc05419109e2704551ee4df43a1a1bfbb90adcfb Mon Sep 17 00:00:00 2001
From: Konstantin Kharlamov <[email-masked]>
Date: Thu, 20 Mar 2025 19:17:32 +0300
Subject: [PATCH] Add major mode for highlighting .npmrc files

* etc/NEWS: mention the new mode.
* lisp/textmodes/conf-mode.el (conf-npmrc-mode): new major mode
derived from conf-mode for highlighting .npmrc files.
* lisp/files.el (auto-mode-alist): associate the new mode with .npmrc
filename.
---
 etc/NEWS                    | 5 +++++
 lisp/files.el               | 1 +
 lisp/textmodes/conf-mode.el | 8 ++++++++
 3 files changed, 14 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index 0797fc03217..8f20ced5589 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1597,6 +1597,11 @@ highlight the fill-column indicators.  By default this is disabled.
 
 * New Modes and Packages in Emacs 31.1
 
+** New major modes that don't depend on the tree-sitter library
+
+*** New major mode 'conf-npmrc-mode'.
+A major mode based on conf-mode purposed for editing ".npmrc" files.
+
 ** New major modes based on the tree-sitter library
 
 *** New major mode 'markdown-ts-mode'.
diff --git a/lisp/files.el b/lisp/files.el
index f85021f0d69..151f20868e7 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3207,6 +3207,7 @@ auto-mode-alist
     ("\\.properties\\(?:\\.[a-zA-Z0-9._-]+\\)?\\'" . conf-javaprop-mode)
     ("\\.toml\\'" . conf-toml-mode)
     ("\\.desktop\\'" . conf-desktop-mode)
+    ("\\.npmrc\\'" . conf-npmrc-mode)
     ("/\\.redshift\\.conf\\'" . conf-windows-mode)
     ("\\`/etc/\\(?:DIR_COLORS\\|ethers\\|.?fstab\\|.*hosts\\|lesskey\\|login\\.?de\\(?:fs\\|vperm\\)\\|magic\\|mtab\\|pam\\.d/.*\\|permissions\\(?:\\.d/.+\\)?\\|protocols\\|rpc\\|services\\)\\'" . conf-space-mode)
     ("\\`/etc/\\(?:acpid?/.+\\|aliases\\(?:\\.d/.+\\)?\\|default/.+\\|group-?\\|hosts\\..+\\|inittab\\|ksysguarddrc\\|opera6rc\\|passwd-?\\|shadow-?\\|sysconfig/.+\\)\\'" . conf-mode)
diff --git a/lisp/textmodes/conf-mode.el b/lisp/textmodes/conf-mode.el
index 6540cb0813c..c97826f54e4 100644
--- a/lisp/textmodes/conf-mode.el
+++ b/lisp/textmodes/conf-mode.el
@@ -664,6 +664,14 @@ conf-desktop-mode
   (conf-mode-initialize "#" 'conf-desktop-font-lock-keywords)
   (conf-quote-normal nil))
 
+;;;###autoload
+(define-derived-mode conf-npmrc-mode conf-mode "Conf[npmrc]"
+ "Conf Mode starter for .npmrc files.
+Comments start with `#' and `;'. For details see `conf-mode'."
+ (conf-mode-initialize "#")
+ (modify-syntax-entry ?\; "<")
+ (modify-syntax-entry ?\# "<"))
+
 (provide 'conf-mode)
 
 ;;; conf-mode.el ends here
-- 
2.48.1