                       (skip-chars-forward (car args))
                       (skip-chars-backward (nth 2 args) pt)
                       (point))))
-             (beg-new beg))
-        ;; (message "ffap-string-at-point dbg: beg = %d end = %d" beg end)
+             (region-len (- (max beg end) (min beg end))))
+
         ;; If the initial characters of the to-be-returned string are the
-        ;; current major mode's comment starter characters, *and* are not part
-        ;; of a comment, remove those from the returned string (Bug#24057).
-        ;; Example comments in `c-mode' (which considers lines beginning with
-        ;; "//" as comments):
+        ;; current major mode's comment starter characters, *and* are
+        ;; not part of a comment, remove those from the returned string
+        ;; (Bug#24057).
+        ;; Example comments in `c-mode' (which considers lines beginning
+        ;; with "//" as comments):
         ;;  //tmp - This is a comment. It does not contain any path reference.
         ;;  ///tmp - This is a comment. The "/tmp" portion in that is a path.
         ;;  ////tmp - This is a comment. The "//tmp" portion in that is a path.


If the point is in a comment, ensure that the returned string does not contain
the comment start characters (especially for major modes that have '//' as
comment start characters).

Sets variables `ffap-string-at-point' and `ffap-string-at-point-region'.

|-----------------------------------+---------------------------------|
| Example string in `c-mode' buffer | Returned `ffap-string-at-point' |

               (null region-selected)
               ;; Check if END character is part of a comment.
               (save-excursion
                 (nth 4 (syntax-ppss end))))
          ;; Move BEG to beginning of comment (after the comment start
          ;; characters), or END, whichever comes first.
          (save-excursion
            (let ((state (syntax-ppss beg)))
              ;; (nth 4 (syntax-ppss)) will be nil for comment start chars
              (unless (nth 4 state)
                (parse-partial-sexp beg end nil nil state :commentstop)
                (setq beg (point))))))

        (if (and (natnump ffap-max-region-length)
                 (< region-len ffap-max-region-length)) ; Bug#25243.
            (setf ffap-string-at-point-region (list beg end)
                  ffap-string-at-point
                  (buffer-substring-no-properties beg end))
          (setf ffap-string-at-point-region (list 1 1)
                ffap-string-at-point ""))))
    (advice-add 'ffap-string-at-point :override #'modi/ffap-string-at-point)))

;; https://github.com/abo-abo/hydra/blob/master/hydra-examples.el
