jed-users mailing list

[2002 Date Index] [2002 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [0.99-15] Problems to read files into the buffer-list.


Martin Klaiber <martinkl@xxxxxxxxxxxxxxxxxx> wrote:
>when programming, I'd like to read all source-files in the current
>directory into the buffer-list on startup. I took some code from
>dired.sl and tried this:

Do you mean to read the files into separate buffers?  If not, then
what do you mean by "buffer-list"?

>define my_ada_fill_buffer_list ()
>{
>  variable my_ada_tmp_buf = make_tmp_buffer_name("my_ada_");
>  variable my_ada_buf = whatbuf();
>  variable s = "";
>
>  sw2buf(my_ada_tmp_buf);
>  shell_cmd (sprintf ("ls %s 2>/dev/null | grep \.ad[bs]$ | sort", "./"));

  Instead of this, I recommend using the slang "listdir" function to
  read the names of files into an array, e.g.,

   foreach (listdir ("."))
     {
	variable file = ();
	variable ext = path_extname (file);
	if ((ext != ".adb") and (ext != ".ads"))
	  continue;
	
	% WHATEVER
	() = read_file (file);
     }

[...]

>  delbuf(my_ada_tmp_buf);
>
>% finally I want to delete my_ada_tmp_buf, but delbuf() asks me, if
>% I really want to kill it. Is there a way to kill my_ada_tmp_buf
>% without prompting me? Again I'm prompted multiple times, as if my
>% function was called recursively.

   You can use 
     
       set_buffer_modified_flag (0);
   
   before calling delbuf.

>Finally I would like to have the list always sorted by name when I
>call it. Is there a way to do this?
     
   Use, e.g.,
     
     foreach (array_sort (listdir (".")))
       {
	  ...
       }

Finally, why not just startup jed as:
   
   jed *.ad[bs]

?

Thanks,
--John

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2002 date index] [2002 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]