Forum OpenACS Development: Response to duplicate queries in .tcl, .xql, -oracle.xql, -postgresql.xql

In my last post I use x-get-selection to get the query name, but this won't work when doing remote work using a tty. To handle that case, you cold use something like the following:

(defun dcw-find-tag-default ()
  "return a string near the point"
  (interactive "")
  (save-excursion
    (while (looking-at "sw|s_")
      (forward-char 1))
    (if (or (re-search-backward "sw|s_"
				(save-excursion (beginning-of-line) (point))
				t)
	    (re-search-forward "(sw|s_)+"
			       (save-excursion (end-of-line) (point))
			       t))
	(progn (goto-char (match-end 0))
	       (buffer-substring (point)
				 (progn (forward-sexp -1)
					(while (looking-at "s'")
					  (forward-char 1))
					(point))))
      nil)))


(defun dcw-find-query ()
  "run grep on selection 
   Uses dcw-find-tag-default to get the grep string 
   that encloses the point"
  (interactive "")
  (let* ((file-name 
          (concat (substring (buffer-file-name) 0 
                             (string-match ".tcl$" 
                                           (buffer-file-name))) "*.xql")))
    (grep (concat "grep -n "query  *name=.*" (dcw-find-tag-default) "" " file-name))))


To use this, you only need to place the cursor on the query name (highlighting the query name is not necessary) string and then hit the function key which is bound to this function. I've also modified the grep string to be more selective, so it should now only return the relevant queries.