* arguments in url question
@ 2008-03-17 2:25 grocery_stocker
2008-03-17 3:16 ` Ben Pfaff
0 siblings, 1 reply; 5+ messages in thread
From: grocery_stocker @ 2008-03-17 2:25 UTC (permalink / raw)
To: help-gnu-emacs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=GB2312, Size: 1081 bytes --]
The following question stems from the following url
http://xahlee.org/emacs/wrap-url.html
The following function on his web page basically makes a url ouf given
a link.
(defun wrap-url-string (url &optional raw)
"Make the string into a html link.\n
Example:
http://en.wikipedia.org/wiki/Emacs
becomes
<a href=\"http://en.wikipedia.org/wiki/Emacs\">Emacs¨J</a>.
If the url is a wikipedia link, then the link text
is shortened to its title.
If the optional argument raw is not nil, no shortening will happen."
(require 'gnus-util)
(let ((linktext url))
(setq linktext (gnus-url-unhex-string linktext nil))
(if (and (not raw) (string-match "wikipedia.org" url))
(progn
(setq linktext (concat (car (last (split-string linktext
"/"))) "¨J") )
)
)
(concat "<a href=\"" url "\">" linktext "</a>" )
)
)
What I don't get is how can a url have optional arguments. I mean
wouldn't something like
¡°http://yahoo.com/news/3829.php¡±
just be passed as one argument to the function i this case?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: arguments in url question
2008-03-17 2:25 arguments in url question grocery_stocker
@ 2008-03-17 3:16 ` Ben Pfaff
2008-03-17 4:00 ` Chad
0 siblings, 1 reply; 5+ messages in thread
From: Ben Pfaff @ 2008-03-17 3:16 UTC (permalink / raw)
To: help-gnu-emacs
grocery_stocker <cdalten@gmail.com> writes:
> The following function on his web page basically makes a url ouf given
> a link.
>
> (defun wrap-url-string (url &optional raw)
[...]
> What I don't get is how can a url have optional arguments.
It's not the URL that has optional arguments in this case. It's
the wrap-url-string function that has an optional argument.
That's a feature of Emacs Lisp, not a feature of a URL.
--
"I admire him, I frankly confess it; and when his time comes
I shall buy a piece of the rope for a keepsake."
--Mark Twain
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: arguments in url question
2008-03-17 3:16 ` Ben Pfaff
@ 2008-03-17 4:00 ` Chad
2008-03-17 4:09 ` Ben Pfaff
0 siblings, 1 reply; 5+ messages in thread
From: Chad @ 2008-03-17 4:00 UTC (permalink / raw)
To: help-gnu-emacs
On Mar 16, 8:16 pm, Ben Pfaff <b...@cs.stanford.edu> wrote:
> grocery_stocker <cdal...@gmail.com> writes:
> > The following function on his web page basically makes a url ouf given
> > a link.
>
> > (defun wrap-url-string (url &optional raw)
>
> [...]
>
> > What I don't get is how can a url have optional arguments.
>
> It's not the URL that has optional arguments in this case. It's
> the wrap-url-string function that has an optional argument.
> That's a feature of Emacs Lisp, not a feature of a URL.
> --
> "I admire him, I frankly confess it; and when his time comes
> I shall buy a piece of the rope for a keepsake."
> --Mark Twain
So what would be the optional argument in this case?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: arguments in url question
2008-03-17 4:00 ` Chad
@ 2008-03-17 4:09 ` Ben Pfaff
2008-03-17 21:34 ` Barry Margolin
0 siblings, 1 reply; 5+ messages in thread
From: Ben Pfaff @ 2008-03-17 4:09 UTC (permalink / raw)
To: help-gnu-emacs
Chad <cdalten@gmail.com> writes:
> On Mar 16, 8:16 pm, Ben Pfaff <b...@cs.stanford.edu> wrote:
>> grocery_stocker <cdal...@gmail.com> writes:
>> > The following function on his web page basically makes a url ouf given
>> > a link.
>>
>> > (defun wrap-url-string (url &optional raw)
>>
>> [...]
>>
>> > What I don't get is how can a url have optional arguments.
>>
>> It's not the URL that has optional arguments in this case. It's
>> the wrap-url-string function that has an optional argument.
>> That's a feature of Emacs Lisp, not a feature of a URL.
>
> So what would be the optional argument in this case?
The one named "raw" in the function declaration quoted above.
--
Ben Pfaff
http://benpfaff.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: arguments in url question
2008-03-17 4:09 ` Ben Pfaff
@ 2008-03-17 21:34 ` Barry Margolin
0 siblings, 0 replies; 5+ messages in thread
From: Barry Margolin @ 2008-03-17 21:34 UTC (permalink / raw)
To: help-gnu-emacs
In article <87wso2800g.fsf@blp.benpfaff.org>,
Ben Pfaff <blp@cs.stanford.edu> wrote:
> Chad <cdalten@gmail.com> writes:
>
> > On Mar 16, 8:16 pm, Ben Pfaff <b...@cs.stanford.edu> wrote:
> >> grocery_stocker <cdal...@gmail.com> writes:
> >> > The following function on his web page basically makes a url ouf given
> >> > a link.
> >>
> >> > (defun wrap-url-string (url &optional raw)
> >>
> >> [...]
> >>
> >> > What I don't get is how can a url have optional arguments.
> >>
> >> It's not the URL that has optional arguments in this case. It's
> >> the wrap-url-string function that has an optional argument.
> >> That's a feature of Emacs Lisp, not a feature of a URL.
> >
> > So what would be the optional argument in this case?
>
> The one named "raw" in the function declaration quoted above.
In other words, you can write
(wrap-url-string "http://en.wikipedia.org/wiki/Emacs")
or
(wrap-url-string "http://en.wikipedia.org/wiki/Emacs" t)
In the latter case, no shortening will be done.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE don't copy me on replies, I'll read them in the group ***
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-03-17 21:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-17 2:25 arguments in url question grocery_stocker
2008-03-17 3:16 ` Ben Pfaff
2008-03-17 4:00 ` Chad
2008-03-17 4:09 ` Ben Pfaff
2008-03-17 21:34 ` Barry Margolin
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.