Function: ffap-dir-separator-near-point

ffap-dir-separator-near-point is a byte-compiled function defined in ffap.el.gz.

Signature

(ffap-dir-separator-near-point)

Documentation

Search backward and forward for closest slash or backlash in line.

Return string slash or backslash. Point is moved to closest position.

Source Code

;; Defined in /usr/src/emacs/lisp/ffap.el.gz
(defun ffap-dir-separator-near-point ()
  "Search backward and forward for closest slash or backlash in line.
Return string slash or backslash.  Point is moved to closest position."
  (let ((point (point))
	str pos)
    (when (looking-at ".*?/")
      (setq str "/"
	    pos (match-end 0)))
    (when (and (looking-at ".*?\\\\")
               (or (null pos)
                   (< (match-end 0) pos)))
      (setq str "\\"
	    pos (match-end 0)))
    (goto-char point)
    (when (and (re-search-backward "/" (line-beginning-position) t)
               (or (null pos)
                   (< (- point (point)) (- pos point))))
      (setq str "/"
	    pos (1+ (point)))) ;1+ to keep cursor at the end of char
    (goto-char point)
    (when (and (re-search-backward "\\\\" (line-beginning-position) t)
               (or (null pos)
		   (< (- point (point)) (- pos point))))
      (setq str "\\"
	    pos (1+ (point))))
    (when pos
      (goto-char pos))
    str))