Easily copy context like the current file name and path, using a convenient transient menu interface!
Every entry in the menu shows a live preview of the value it would copy — labels on the left, values on the right. Entries that don't apply to the current buffer are grayed out.
- File name - Copy base file name (e.g.,
file.el) - Relative path - Copy relative path from project root (e.g.,
src/lib/file.el) - Full path - Copy absolute file path
- Directory - Copy directory path (or default directory for non-file buffers)
- File with line - Copy file name with line number (e.g.,
file.el:123) - ... and more!
- Clone or download this repository:
git clone https://github.com/mrcnski/context-clues.git ~/.emacs.d/packages/context-clues- Add to your Emacs configuration:
(add-to-list 'load-path "~/.emacs.d/packages/context-clues")
(require 'context-clues)(use-package context-clues
:load-path "~/.emacs.d/packages/context-clues"
:bind ("C-c c" . context-clues))Run M-x context-clues to open the transient menu, then press the corresponding key to copy:
f- Copy file nameF- Copy full path (absolute)d- Copy directory- etc.
Customize the message shown after copying:
(setq context-clues-message-format "Copied: {text} ({description})")Use {text} for the copied text and {description} for the description (e.g., "file name"). You can reorder them as needed:
;; Show description first
(setq context-clues-message-format "{description}: {text}")Long values are truncated at the front (keeping the tail — for paths, the distinctive part). Customize the width and the face:
(setq context-clues-preview-max-width 60) ; default 50The previews use the context-clues-preview-face face (inherits shadow by
default); customize it with M-x customize-face.
Bind to a convenient key:
(global-set-key (kbd "C-c c") 'context-clues)- Emacs 28.1 or later
GPL-3.0-or-later