jed-users mailing list

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

Re: [jed-users] inverse function of buffer_filename() ?


Ulli Horlacher <framstag@xxxxxxxxxxxxxxxxxxxx> wrote:
> I need the inverse function of buffer_filename(): obtain the buffer
> associated with a file.

Perhaps the following will meet your needs.  If no matching buffer
exists, then it returns NULL.  --John

define filename_buffer (file)
{
   file = expand_filename (file); %  convert to canonical form

   variable buf_name, buf_file, buf_dir;

   foreach buf_name ([buffer_list(), pop ()])
     {
        (buf_file, buf_dir,,) = getbuf_info (buf_name);
        if (file == strcat (buf_dir, buf_file))
          return buf_name;
     }
   return NULL;
}
_______________________________________________
For list information, visit <http://jedsoft.org/jed/mailinglists.html>.


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