Function: ido-copy-current-word

ido-copy-current-word is an interactive and byte-compiled function defined in ido.el.gz.

Signature

(ido-copy-current-word ALL)

Documentation

Insert current word (file or directory name) from current buffer.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/ido.el.gz
(defun ido-copy-current-word (_all)
  "Insert current word (file or directory name) from current buffer."
  (interactive "P")
  (let ((word (with-current-buffer ido-entry-buffer
		(let ((p (point)) start-line end-line start-name)
		  (if (and mark-active (/= p (mark)))
		      (setq start-name (mark))
		    (beginning-of-line)
		    (setq start-line (point))
		    (end-of-line)
		    (setq end-line (point))
		    (goto-char p)
		    (if (re-search-backward "[^-_a-zA-Z0-9:./\\~@]" start-line 1)
			(forward-char 1))
		    (setq start-name (point))
		    (re-search-forward "[-_a-zA-Z0-9:./\\~@]*" end-line 1)
		    (if (= start-name (point))
			(setq start-name nil)))
		  (and start-name
		       (buffer-substring-no-properties start-name (point)))))))
    (if (cond
	 ((not word) nil)
	 ((string-match "\\`[~/]" word)
	  (setq ido-text-init word
		ido-try-merged-list nil
		ido-exit 'chdir))
	 ((string-search "/" word)
	  (setq ido-text-init (concat ido-current-directory word)
		ido-try-merged-list nil
		ido-exit 'chdir))
	 (t
	  (setq ido-text-init word
		ido-try-merged-list nil
		ido-exit 'refresh)))
	(exit-minibuffer))))