help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: operations on path lists


From: James Thomas
Subject: Re: operations on path lists
Date: Sat, 11 Feb 2023 13:48:39 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1.90 (gnu/linux)

Samuel Wales wrote:

> 1.  shortcut all subsequent paths
>
> if a path is like ./.../...foo.../.../...foo..., then eliminate that line.
> i.e. eliminate paths that have common prefix paths on any previous line.

(With point at the beginning, do) M-x replace-regexp RET, then paste the
following expression (without quotes - note the newline at the
beginning), then RET twice.

"
.*\(/[^/
]*foo[^/
]\).*\1.*$"

> 2.  highlight adjacent subsequent paths' common components
>
> if i have paths like
>
> ./hi/foo
> ./hi/there/foo
> ./whatever/whatever/foo
>
> then i want line 2 to have ./hi/ highlighted.  i might also like this
> one for, not paths, but lines, to show intra-component differences.
> but in that case, it might be the difference i want highlghted, and it
> need not be a prefix or a suffix.

This can also be done with a similar regexp. I suggest you get familiar
with "Syntax of Regexps" in the Elisp manual. You will also need this:

https://emacs.stackexchange.com/questions/37272/highlight-different-regexp-groups-with-different-colors

> and suppose that i want to copy these dirs to another dir, or so.  the
> components and paths can be long.

Additionally, you can set the resulting buffer in dired-virtual-mode
(from the dired-x package) and then run:

M-: (setq-local directory-listing-before-filename-regexp " +") RET

...to use it as a normal dired buffer (for copying, deleting etc).

--



reply via email to

[Prev in Thread] Current Thread [Next in Thread]