Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 698750 - app-emacs/ebuild-mode: enable syntax highlighting on package.{env,mask,unmask,use}
Summary: app-emacs/ebuild-mode: enable syntax highlighting on package.{env,mask,unmask...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Emacs project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-28 14:07 UTC by Joonas Niilola
Modified: 2020-07-23 10:59 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joonas Niilola gentoo-dev 2019-10-28 14:07:35 UTC
Hey, 

just a thought I had. Vim has syntax highlighting for these files, so I thought it can't be impossible on emacs to have. Not sure if ebuild-mode is the correct package for that, or should some more generic package be created (like, gentoo-mode)? Thoughts and other input appreciated.
Comment 1 Ulrich Müller gentoo-dev 2019-10-28 17:01:04 UTC
I'd suggest using conf-mode for this.

The problem is more to come up with a definitive list of filenames for which it should be activated. There is a list in the portage(5) manpage, but we'll have to see which files we want.
Comment 2 Joonas Niilola gentoo-dev 2020-06-23 10:57:33 UTC
Something like worked for me so far
(note that I'm a first-timer writing lisp), 

diff -Naur ebuild-mode-1.50/ebuild-mode.el ebuild-mode-1.51/ebuild-mode.el
--- ebuild-mode-1.50/ebuild-mode.el	2020-03-08 00:36:27.000000000 +0200
+++ ebuild-mode-1.51/ebuild-mode.el	2020-06-23 13:54:33.203458004 +0300
@@ -555,7 +555,8 @@
   "\n"
   ;; dependencies
   "RDEPEND=\"\"\n"
-  "DEPEND=\"\$\{RDEPEND\}\"\n")
+  "DEPEND=\"\$\{RDEPEND\}\"\n"
+  "BDEPEND=\"\"\n")
 
 
 ;;; Keybindings.
@@ -589,6 +590,10 @@
 ;;;###autoload
 (add-to-list 'auto-mode-alist '("\\.\\(ebuild\\|eclass\\)\\'" . ebuild-mode))
 
+;;; Enable conf-mode for Gentoo-specific /etc/portage config files,
+(add-to-list 'auto-mode-alist '(
+  "\\package.\\(accept_keywords\\|env\\|mask\\|unmask\\|use\\)\\'" . conf-mode))
+
 (provide 'ebuild-mode)
 
 ;; Local Variables:


At least package.unmask seems a bit redundant, but it's there for consistency's sake.
Comment 3 Joonas Niilola gentoo-dev 2020-06-23 12:18:37 UTC
Here's the full list of 'man 5 portage' file names: 
  https://dev.gentoo.org/~juippis/tmp/etcportagefilenames.txt

First of all we can obviously ignore any .conf files, since they get conf-mode enabled by default. (make.conf, repo.conf, sets.conf, env.conf)

From a user's point of view, let's focus on /etc/portage/: 
 - as a Gentoo emacs user, I'd say the following list would benefit me:
   - package.{accept_keywords,env,mask,unmask,use},
   - which leaves out:
     - bashrc, 
     - package.{accept_restrict,keywords(deprecated),license,properties}
     - random files which I have no idea about their content, probably not relevant to users
 - even package.mask and .unmask are a bit questionable, since they only have one entry per-line, but conf-mode follows color scheme better than Fundamental.

Now on a Gentoo dev's point of view, we must also include /var/db/repos/gentoo/profiles/ because every now and then we edit these files: 
 - package.{mask,unmask,use{.force,.mask,.stable.force,.stable.mask}}
 - use.{force,mask,stable.mask,stable.force}

Maybe add conf-mode for /var/lib/portage/world{_sets}. Same rationale as with .mask & .unmask, conf-mode supports my colorscheme better than Fundamental. I believe from a user's and developers' point of view, rest can be ignored.

So this'd be the final list, in a simple form: 

  package.accept_keywords
  package.env
  package.mask
  package.unmask
  package.use

  package.use.force
  package.use.mask
  package.use.stable.force
  package.use.stable.mask
  use.force
  use.mask
  use.stable.mask
  use.stable.force

  (/var/lib/portage/)world
  (/var/lib/portage/)world_sets

Some regexp magic can surely be used here. () indicate a possible full path instead of blankly matching per file name.
Comment 4 Larry the Git Cow gentoo-dev 2020-07-21 20:26:38 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=266c57d3caec4df8fe747e10cfbf8cf55cf7de70

commit 266c57d3caec4df8fe747e10cfbf8cf55cf7de70
Author:     Ulrich Müller <ulm@gentoo.org>
AuthorDate: 2020-07-21 20:25:42 +0000
Commit:     Ulrich Müller <ulm@gentoo.org>
CommitDate: 2020-07-21 20:26:30 +0000

    app-emacs/ebuild-mode: Version bump to 1.51.
    
    Closes: https://bugs.gentoo.org/698750
    Package-Manager: Portage-3.0.0, Repoman-2.3.23
    Signed-off-by: Ulrich Müller <ulm@gentoo.org>

 app-emacs/ebuild-mode/Manifest                     |  1 +
 app-emacs/ebuild-mode/ebuild-mode-1.51.ebuild      | 22 ++++++++++++++++++++++
 .../ebuild-mode/files/50ebuild-mode-gentoo-1.51.el | 21 +++++++++++++++++++++
 3 files changed, 44 insertions(+)
Comment 5 Ulrich Müller gentoo-dev 2020-07-21 20:27:43 UTC
I've enabled conf-mode via the site-init file in ebuild-mode-1.51:

(add-to-list 'auto-mode-alist
	     '("/\\(package\\.\\(use\\|env\
\\|license\\|properties\\|accept_\\(keywords\\|restrict\\)\\)\
\\|\\(package\\.\\)?use.\\(stable\\.\\)?\\(force\\|mask\\)\\)\\'"
	       . conf-mode))
Comment 6 Ulrich Müller gentoo-dev 2020-07-22 10:31:03 UTC
(In reply to Ulrich Müller from comment #5)
> I've enabled conf-mode via the site-init file in ebuild-mode-1.51:
> 
> (add-to-list 'auto-mode-alist
> 	     '("/\\(package\\.\\(use\\|env\
> \\|license\\|properties\\|accept_\\(keywords\\|restrict\\)\\)\
> \\|\\(package\\.\\)?use.\\(stable\\.\\)?\\(force\\|mask\\)\\)\\'"
> 	       . conf-mode))

... which misses package.mask and package.unmask. Added now (in -r1).
Comment 7 Ulrich Müller gentoo-dev 2020-07-23 10:59:10 UTC
Also, we should use conf-space-mode instead of the generic conf-mode. Fixed in -r3.