mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Add a new Eshell special reference type for markers
* lisp/eshell/esh-arg.el (eshell-get-marker, eshell-insert-marker) (eshell-complete-marker-ref): New functions... (eshell-special-ref-alist): ... Add them to the new "marker" entry. * test/lisp/eshell/esh-arg-tests.el (esh-arg-test/special-reference/marker) (esh-arg-test/special-reference/nested) (esh-arg-test/special-reference/lisp-form): * test/lisp/eshell/em-cmpl-tests.el (em-cmpl-test/special-ref-completion/type) (em-cmpl-test/special-ref-completion/marker): New tests. * doc/misc/eshell.texi (Arguments): Document the new special ref type. * etc/NEWS: Announce this change (bug#66458).
This commit is contained in:
parent
69e8333210
commit
64aa01f60a
5 changed files with 110 additions and 3 deletions
|
|
@ -169,7 +169,11 @@ treated as a literal character."
|
|||
'(("buffer"
|
||||
(creation-function eshell-get-buffer)
|
||||
(insertion-function eshell-insert-buffer-name)
|
||||
(completion-function eshell-complete-buffer-ref)))
|
||||
(completion-function eshell-complete-buffer-ref))
|
||||
("marker"
|
||||
(creation-function eshell-get-marker)
|
||||
(insertion-function eshell-insert-marker)
|
||||
(completion-function eshell-complete-marker-ref)))
|
||||
"Alist of special reference types for Eshell.
|
||||
Each entry is a list of the form (TYPE (KEY VALUE)...). TYPE is
|
||||
the name of the special reference type, and each KEY/VALUE pair
|
||||
|
|
@ -717,5 +721,26 @@ single argument."
|
|||
"Perform completion for buffer references."
|
||||
(pcomplete-here (mapcar #'buffer-name (buffer-list))))
|
||||
|
||||
(defun eshell-get-marker (position buffer-or-name)
|
||||
"Return the marker for character number POSITION in BUFFER-OR-NAME.
|
||||
BUFFER-OR-NAME can be a buffer or a string. If a string and a
|
||||
live buffer with that name exists, use that buffer. If no such
|
||||
buffer exists, create a new buffer with that name and use it."
|
||||
(let ((marker (make-marker)))
|
||||
(set-marker marker (string-to-number position)
|
||||
(get-buffer-create buffer-or-name))))
|
||||
|
||||
(defun eshell-insert-marker (position buffer-name)
|
||||
"Insert a marker into the current buffer at point.
|
||||
This marker will point to POSITION in BUFFER-NAME."
|
||||
(interactive "nPosition: \nBName of buffer: ")
|
||||
(insert-and-inherit "#<marker " (number-to-string position) " "
|
||||
(eshell-quote-argument buffer-name) ">"))
|
||||
|
||||
(defun eshell-complete-marker-ref ()
|
||||
"Perform completion for marker references."
|
||||
(pcomplete-here)
|
||||
(pcomplete-here (mapcar #'buffer-name (buffer-list))))
|
||||
|
||||
(provide 'esh-arg)
|
||||
;;; esh-arg.el ends here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue