1561 |
|
|
1562 |
;;; Internal functions. |
;;; Internal functions. |
1563 |
|
|
1564 |
;; Fixme: This should probably be replaced with `thing-at-point', but |
;; Fixme: This should probably use `thing-at-point'. -- fx |
|
;; that needs checking for compatibility. -- fx |
|
1565 |
(defun dired-filename-at-point () |
(defun dired-filename-at-point () |
1566 |
"Get the filename closest to point, but do not change position. |
"Get the filename closest to point, but do not change position. |
1567 |
Has a preference for looking backward when not directly on a symbol. Not |
Has a preference for looking backward when not directly on a symbol. Not |
1568 |
perfect - point must be in middle of or end of filename." |
perfect - point must be in middle of or end of filename." |
1569 |
|
|
1570 |
(let ((filename-chars "-.[:alnum:]_/:$+@") |
(let ((filename-chars "-.[:alnum:]_/:$+@") |
|
(bol (save-excursion (beginning-of-line) (point))) |
|
|
(eol (save-excursion (end-of-line) (point))) |
|
1571 |
start end filename prefix) |
start end filename prefix) |
1572 |
|
|
1573 |
(save-excursion |
(save-excursion |
1582 |
(if (string-match (concat "[" filename-chars "]") |
(if (string-match (concat "[" filename-chars "]") |
1583 |
(char-to-string (following-char))) |
(char-to-string (following-char))) |
1584 |
(progn |
(progn |
1585 |
(skip-chars-backward filename-chars) |
(if (re-search-backward (concat "[^" filename-chars "]") nil t) |
1586 |
|
(forward-char) |
1587 |
|
(goto-char (point-min))) |
1588 |
(setq start (point)) |
(setq start (point)) |
1589 |
(setq prefix |
(setq prefix |
1590 |
(and (string-match "^\\w+@" |
(and (string-match |
1591 |
(buffer-substring start eol)) |
"^\\w+@" |
1592 |
|
(buffer-substring start (line-beginning-position))) |
1593 |
"/")) |
"/")) |
1594 |
(goto-char start) |
(goto-char start) |
1595 |
(if (string-match "[/~]" (char-to-string (preceding-char))) |
(if (string-match "[/~]" (char-to-string (preceding-char))) |
1596 |
(setq start (1- start))) |
(setq start (1- start))) |
1597 |
(skip-chars-forward filename-chars)) |
(re-search-forward (concat "\\=[" filename-chars "]*") nil t)) |
1598 |
|
|
1599 |
(error "No file found around point!")) |
(error "No file found around point!")) |
1600 |
|
|