- Subject: confine search to visible lines
 
- From: "G. Milde" <milde@xxxxxxxxxxxxxxxxxxxxx>
 
- Date: Thu, 22 May 2008 11:11:11 +0200
 
Dear jed-users,
the patch below defines two functions 
 search_forward_visible()
 search_backward_visible()
that search only in visible text (skipping hidden lines).
Alternatively, a new global variable 
  SEARCH_SKIP_HIDDEN 
or
  SEARCH_VISIBLE  
  
could be used to implement this feature.
Comparing these 2 approaches, I spotted these (dis)advantages:
separate *_visible() functions:
 + can be bound to a separate key easily for fast acces to either
   visible-only or all-including searches
   
 - new functions needed for every type of search (incremental, standard,
   regexp, pcre-regexp, replace, re-replace)
   
new toggeling variable:
 + easier implementation, less code duplication
   (the search_generic_search() functions provides
   for a "match_ok" function) 
 - parallel bindings for visible-only and all-including searches would
   need a wrapper function that changes and resets the SEARCH_VISIBLE
   variable
     
Which interface would you prefer? (I'd tend towards the SEARCH_VISIBLE
variable)
Günter
--- /usr/share/jed/lib/search.sl	2008-04-22 14:43:08.000000000 +0200
+++ /home/milde/.jed/lib/search.sl	2008-05-21 23:26:25.000000000 +0200
@@ -90,6 +90,25 @@
    search_generic_search ("Search backward:", -1, &_function_return_1);
 }
 
+% this should go to srchmisc.sl
+% a match_ok_fun for search_maybe_again():
+%  no arguments, return 1 if match is OK
+private define is_line_visible() 
+{
+   return not(is_line_hidden ());
+}
+
+% search forward (ask for pattern, skip hidden matches)
+define search_forward_visible ()
+{
+   search_generic_search ("Search forward:", 1, &is_line_visible);
+}
+
+% search backward (ask for pattern, skip hidden matches)
+define search_backward_visible ()
+{   
+   search_generic_search ("Search backward:", -1, &is_line_visible);
+}
 
 define replace_do_replace (str, len)
 {
--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.
  [2008 date index]
  [2008 thread index]
  
  [Thread Prev] [Thread Next]
      
  [Date Prev] [Date Next]