jed-users mailing list

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

Re: Patches for jed


=?UTF-8?Q?J=C3=B6rg?= Sommer <joerg@xxxxxxxxxxxx> wrote:
>I'd like to here your opinion to the following patches.

I implemented (and checked-in) all the patches (with minor
modifications) except for the last patch:

>http://www.minet.uni-jena.de/~joergs/jed-patches/slmode-function-popup.dpatch

I was unable to access the above URL.

FWIW, I utilized the curl module to download the patches into a jed
buffer.  This made it easier for me to inspect and merge the
patches.  There may be similar functionality in the jed mode's
repository, but I had these lying around.  --John

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% public functions:
%
%  browse_url ([url])
%  download_url ([url [,bufname]])

require ("curl");

custom_variable ("WWW_Browser", "lynx '%s'");

private define extract_url ()
{
   variable valid_chars = "-a-zA-Z0-9_/.:?&~=";

   push_spot ();
   bskip_chars (valid_chars); 
   push_mark();
   skip_chars (valid_chars);
   variable url = bufsubstr();
   pop_spot ();
   
   url = strtrim_beg (url, ".:?&-=");
   url = strtrim_end (url, ".:&?");
   return url;
}


private define get_url_args (nargs, urlp, bufnamep)
{
   variable url, bufname;

   switch (nargs)
     {
      case 1:
	url = ();
	bufname = whatbuf ();
     }
     {
      case 2:
	(url, bufname) = ();
     }
     {
      case 0:
	url = extract_url ();
	url = read_mini("Download URL:", "", url);
	if (bufnamep != NULL)
	  {
	     bufname = path_basename (url);
	     if (is_substr (bufname, "?"))
	       bufname = substr (bufname, 1, is_substr (bufname, "?", 0)-1);
	     bufname = read_mini ("Buffer name:", bufname, "");
	  }
     }
     {
	verror ("get_url_args: Wrong number of args");
     }

   if (0 == strlen (url))
     return -1;

   if (bufnamep != NULL)
     @bufnamep = bufname;

   @urlp = url;
   return 0;
}

define browse_url ()
{
   variable url;
   if (0 == get_url_args (_NARGS, &url, NULL))
     vrun_program (WWW_Browser, url);
}

private define write_to_buffer (unused, data)
{
   insert (data);
   return 0;
}

private define download_url_to_buffer (url, buf)
{
   setbuf (buf);
   variable c = curl_new (url);
   curl_setopt (c, CURLOPT_FOLLOWLOCATION);
   curl_setopt (c, CURLOPT_WRITEFUNCTION, &write_to_buffer, NULL);
   curl_setopt (c, CURLOPT_HTTPHEADER, 
		["User-Agent: firefox",
		 "Content-Type: application/x-www-form-urlencoded",
		 "Accept-Charset: ISO-8859-1,utf-8"
		]);
   variable e;
   curl_perform (c);
}

define download_url ()
{
   variable url, bufname;

   if (-1 == get_url_args (_NARGS, &url, &bufname))
     return;
   download_url_to_buffer (url, bufname);
   pop2buf (bufname);
}

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


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