0

I am using emacs to code in Verilog/SystemVerilog and the commented lines begin with //.

I like to use the "ido find files at point" and so I have '(ido-use-filename-at-point (quote guess)) in custom-set-variables.

It works perfectly except when I am trying to open another file while my cursor is on the first word of a comment like //Revision Control:. It tries to find a file called Revision in // path.

How can I disable the ido ffap functionality for the root / and // paths? Another way that would serve the functionality is if the ido ffap disables automatically on lines starting with //.

1 Answer 1

0

Assuming that there are no special ffap-handlers for verilog-mode yet in ffap-alist the following code should do the trick:

(defun ffap-verilog (name) (let ((inhibit-changing-match-data t) ;; string-match should not change match data (ppss (syntax-ppss))) (if (and (eq (syntax-ppss-context ppss) 'comment) ;; we are inside a comment (= (line-number-at-pos (nth 8 ppss)) (line-number-at-pos (point))) ;; limit the match to the line starting the comment (string-match "/[/*]\\([[:alnum:]_.]\\)+$" (buffer-substring-no-properties (nth 8 ppss) (point)))) "" name))) (add-to-list 'ffap-alist '(verilog-mode . ffap-verilog) 'append) 

The special case is checked that the leading // or /* of a comment is directly followed by a string which could be miss-interpreted by ffap as an url or a path with wildcard. Note however, that other strings inside of a comment starting with \\ are not handled since these could really be urls.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.