Nedit has a very cool feature and I’ve even seen people using gvim have something similar. However emacs for some reason doesn’t. Is it because they don’t have users of their same field of application? Well who knows.
The feature in question that with Ctrl-y on Nedit one can open a file whose filename and path are listed in a text file just by placing the cursor on that
#---------------------- #!/usr/bin/tclsh source $(SCRIPTS_HOME)/definitions.tcl .... #----------------------
After several nights roaming online for a possible solution with emacs, I ended thinking that there is no generic for this. Hence I ended up writing the following lisp code myself with my 4-hours experience with lisp.
The objective is there is an environmental variable for each projects’ path and that each has specific technology files (LEF,Liberty(ccs,ecsm,…) for pads, sram, rom, analog modules, …… One should be able to open the $(SCRIPTS_HOME)/definitions.tcl (with a shortcut i.e Ctrl-Y) within emacs itself , instead of ctrl-x-f ?
;; ;; Nedit file open with control-y ;; (defun cgo-open-this-file (arg) "Copy lines (as many as prefix argument) in the kill ring" (interactive "p") ;; select whole word (let (b1 b2) (skip-chars-backward "^<>“[\"‘") (setq b1 (point)) (skip-chars-forward "^<>”]\"’") (setq b2 (point)) (set-mark b1)) ;; grab selected word and start processing it (setq filename (if (and transient-mark-mode mark-active) (buffer-substring-no-properties (region-beginning) (region-end)) (thing-at-point 'symbol))) ;; identify a environmentalvariable (setq envvar (replace-regexp-in-string ".*$(" "" filename)) (setq envvar (replace-regexp-in-string ").*" "" envvar)) (setq envvar (getenv envvar)) (message "envvar %s" envvar) ;; replacing the environmental variable (setq envvar_replacement (replace-regexp-in-string "\$(.*)" envvar filename)) (message "file %s" envvar_replacement) (find-file envvar_replacement) ) ;; optional key binding (global-set-key "\C-y" 'cgo-open-this-file)
This code can be improved to support multiple env variables or any thing you would like, However it works and suits my application. Feel free to post a better solution