How to make the "package" column of Emacs' ELPA list-packages screen wider?
Asked Answered
E

5

8

When I run list-packages on Emacs 24, I get a screen that looks like the following:

ELPA

The problem is that many packages' names are longer than the package column. How do I make this column wider so that I can see the full package names?

Ealing answered 7/2, 2015 at 19:18 Comment(0)
I
3

Maybe there is a more elegant solution but I came up with this. You can define the width of the column using following code and changing the variable package-menu-column-width to your needs. Then, you need to include it to your init file (after (require 'package)). It is from the package.el file which defines the format of the table. See the first comment inside the code where you need to modify the width of the column. You can proceed in a similar way for the other columns.

;; <<<< here you have to adapt the number to your needs >>>>
(defcustom package-menu-column-width 18
  "Width of the package column."
  :type 'number
  :group 'package)

(define-derived-mode package-menu-mode tabulated-list-mode "Package Menu"
  "Major mode for browsing a list of packages.
Letters do not insert themselves; instead, they are commands.
\\<package-menu-mode-map>
\\{package-menu-mode-map}"
  (setq tabulated-list-format
        `[("Package" ,package-menu-column-width package-menu--name-predicate)
          ("Version" 12 nil)
          ("Status"  10 package-menu--status-predicate)
          ,@(if (cdr package-archives)
                '(("Archive" 10 package-menu--archive-predicate)))
          ("Description" 0 nil)])
  (setq tabulated-list-padding 2)
  (setq tabulated-list-sort-key (cons "Status" nil))
  (add-hook 'tabulated-list-revert-hook 'package-menu--refresh nil t)
  (tabulated-list-init-header))
Indefectible answered 7/2, 2015 at 20:26 Comment(1)
I had to do the same thing. It seems like a patch to the package.el file is in order to allow customized column widths!Rayburn
L
0

The http://www.github.com/purcell/emacs.d repository includes the following in the lisp/init-elpa.el setup file which looks like it would address your problem.

(require-package 'cl-lib)
(require 'cl-lib)

(defun sanityinc/set-tabulated-list-column-width (col-name width)
  "Set any column with name COL-NAME to the given WIDTH."
  (cl-loop for column across tabulated-list-format
           when (string= col-name (car column))
           do (setf (elt column 1) width)))

(defun sanityinc/maybe-widen-package-menu-columns ()
  "Widen some columns of the package menu table to avoid truncation."
  (when (boundp 'tabulated-list-format)
    (sanityinc/set-tabulated-list-column-width "Version" 13)
    (let ((longest-archive-name (apply 'max (mapcar 'length (mapcar 'car package-archives)))))
      (sanityinc/set-tabulated-list-column-width "Archive" longest-archive-name))))

(add-hook 'package-menu-mode-hook 'sanityinc/maybe-widen-package-menu-columns)
Louth answered 12/2, 2015 at 21:27 Comment(0)
W
0

I do know this is an old question, but I hope my answer may be useful.... (btw I've checked it with emacs 26.1 and package manager 1.1.0 running on Windows 8.1)

let's find 'package.el' file - in my system it's in folder:

d:\Program Files2\emacs\share\emacs\26.1\lisp\emacs-lisp\

open it in your emacs ... find a piece of code looking like this one: (in my system these are lines 2553..2559 of 'package.el' file)

(setq tabulated-list-format
    `[("Package" 18 package-menu--name-predicate)
      ("Version" 13 nil)
      ("Status"  10 package-menu--status-predicate)
      ,@(if (cdr package-archives)
            '(("Archive" 13 package-menu--archive-predicate)))
      ("Description" 0 nil)])                                 

As You can see here are the package manager columns width definitions. Change the width of the appropriate column(s) according to your needs ... (in my case 18 -> 25, 13 -> 15, 10 -> 10, 13 -> 15 was enough).

'byte-compile' this file (e.g. pick this option in 'Emacs-Lisp' menu) you should receive the message:

"Wrote \package.elc"

restart Emacs

Voila!

PS: Of course this is not elegant and only temporary solution; It works until next Emacs update only (of course you can repeat this procedure after emacs update...)

Woodall answered 19/7, 2018 at 17:4 Comment(0)
A
0

The answer by Tim X above is the closest to what I think is what is wanted - however the function there calculates the length of the largest item in the "Archive" column before setting the relevant column width. In order to achieve the "Package" column being sized to the largest item in it, I found the below worked for me:

(require 'cl-lib)
(defun godeater/set-tabulated-list-column-width (col-name width)
  "Set any column with the name COL-NAME to the given WIDTH."
  (cl-loop for column across tabulated-list-format
       when (string= col-name (car column))
       do (setf (elt column 1) width)))

(defun godeater/maybe-widen-package-menu-columns ()
  "Widen some columns of the package menu table to avoid truncation."
  (when (boundp 'tabulated-list-format)
    (godeater/set-tabulated-list-column-width "Version" 13 )
    (let ((longest-package-name (apply 'max (mapcar 'length (mapcar 'symbol-name (mapcar 'car package-archive-contents))))))
      (godeater/set-tabulated-list-column-width "Package" longest-package-name))))

(add-hook 'package-menu-mode-hook 'godeater/maybe-widen-package-menu-columns)
Associationism answered 14/12, 2018 at 20:50 Comment(0)
F
0

Here's my take on this. It adds a package-menu-mode hook (like the purcell solution) and modifies tabulated-list-format in a more concise fashion than the other solutions. It also widens the "Archive" column because I hated seeing melpa-s... instead of melpa-stable. (Yes, the column had the ellipsis.) I didn't bother with some function that calculates the column width on the fly because it's not going to change often and almost every package name is going to be less than or equal to it.

(defcustom dse/package-menu/package-column-width 32
  "Column width of package name in list-packages menu."
  :type 'number :group 'package)
(defcustom dse/package-menu/archive-column-width 12
  "Column width of archive name in list-packages menu."
  :type 'number :group 'package)
(defun dse/package-menu/fix-column-widths ()
  (let ((tlf (append tabulated-list-format nil)))
    (setf (cadr (assoc "Package" tlf)) dse/package-menu/package-column-width)
    (setf (cadr (assoc "Archive" tlf)) dse/package-menu/archive-column-width)
    (setq tabulated-list-format (vconcat tlf))))

(add-hook 'package-menu-mode-hook #'dse/package-menu/fix-column-widths)
Flee answered 26/10, 2019 at 6:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.