Function: wdired-get-filename
wdired-get-filename is a byte-compiled function defined in
wdired.el.gz.
Signature
(wdired-get-filename &optional NO-DIR OLD)
Documentation
Return the filename at line.
Similar to dired-get-filename but it doesn't rely on regexps. It
relies on WDired buffer's properties. Optional arg NO-DIR with value
non-nil means don't include directory. Optional arg OLD with value
non-nil means return old filename.
Source Code
;; Defined in /usr/src/emacs/lisp/wdired.el.gz
(defun wdired-get-filename (&optional no-dir old)
"Return the filename at line.
Similar to `dired-get-filename' but it doesn't rely on regexps. It
relies on WDired buffer's properties. Optional arg NO-DIR with value
non-nil means don't include directory. Optional arg OLD with value
non-nil means return old filename."
;; FIXME: Use dired-get-filename's new properties.
(let ((used-F (dired-check-switches dired-actual-switches "F" "classify"))
beg end file)
(wdired--before-change-fn (point) (point))
(save-excursion
(setq end (line-end-position))
(beginning-of-line)
(setq beg (next-single-property-change (point) 'old-name nil end))
(unless (eq beg end)
(if old
(setq file (get-text-property beg 'old-name))
;; In the following form changed `(1+ beg)' to `beg' so that
;; the filename end is found even when the filename is empty.
;; Fixes error and spurious newlines when marking files for
;; deletion.
(setq end (next-single-property-change beg 'end-name nil end))
(when (save-excursion
(and (re-search-forward
dired-permission-flags-regexp nil t)
(goto-char (match-beginning 0))
(looking-at "l")
(if (and used-F
dired-ls-F-marks-symlinks)
(re-search-forward "@? -> " (line-end-position) t)
(search-forward " -> " (line-end-position) t))))
(goto-char (match-beginning 0))
(setq end (point)))
(when (and used-F
(save-excursion
(goto-char end)
(looking-back "[*/@|=>]$" (1- (point)))))
(setq end (1- end)))
(setq file (buffer-substring-no-properties (1+ beg) end)))
;; Don't unquote the old name, it wasn't quoted in the first place
(and file (setq file (wdired-normalize-filename file (not old)))))
(if (or no-dir old)
(if no-dir (file-relative-name file) file)
(and file (> (length file) 0)
(concat (dired-current-directory) file))))))