[Bibdesk-users] Script hook to protect Address field

2010-04-01 Thread Peter Cowan
I'm using biblatex in the TeX preview window.  And, since I often
import directly from ISI using the Web of Science Search function, I
get regular errors related to commas in the address or institution
field.  Perhaps there is a solution through biblatex to this problem,
but I'm fine with either protecting or deleting the
Address/Institution field on import.

Script hooks seem like the perfect solution to this problem, but I am
not an applescript users.  I've tried to cobble something together
based on the available example and got the following which doesn't
appear to work, on import (from Web of Science) nothing happens no
errors no braces.  Any nudges in the right direction are appreciated.

I apologize if this has been discussed on the list before, my searches
did not reveal anything aside from confirmation of the biblatex TeX
preview issue.

Cheers

Peter

set protectLib to (load script file ¬
((path to home folder as string)  Library:Application
Support:BibDesk:Scripts:Add Protect Strings.scpt))
-- load the Error Reporting script library
set errorLib to (load script file ¬
((path to home folder as string)  Library:ScriptingAdditions:Error
Reporting.scpt))
-- we only report all errors at the end
tell errorLib
delayReportErrors()
set its defaultErrorFileName to BibDeskScriptErrors
end tell

property theFieldToSet : Address

using terms from application BibDesk
on perform BibDesk action with publications thePubs for script hook
theScriptHook

-- here you could return depending on theName or theField
tell protectLib
-- protect chars between balanced {}
set its startProtectChar to {
set its endProtectChar to }

repeat with thePub in thePubs

try
tell thePub
set curValue to value of field 
theFieldToSet
-- generate a new value for the 
field
set theField to field 
theFieldToSet
set newValue to 
protectString(curValue)
if newValue is not {} then ¬
set value of theField 
to newValue
end tell

on error errorMessage number errorNumber
tell errorLib to 
reportError(errorMessage, errorNumber)

end try

end repeat
end tell --protectLib

end perform BibDesk action with publications
end using terms from

-- see if we had any errors
tell errorLib to checkForErrors()

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Bibdesk-users mailing list
Bibdesk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-users


Re: [Bibdesk-users] Bibdesk punctuation question

2010-04-01 Thread Dan T. Abell
Dear Joe,

This is actually a BibTeX question, as it's BibTeX that
controls the formatting of the bibliographic data. I
haven't found a .bst file that formats as you request,
though I'm sure one exists (if for no other reason
than typography guru Robert Bringhurst recommends one
put little or no space between initials).

Assuming you can't get the journal to supply you with
an appropriate bibliography style file, then here, very
roughly, is what you need to do:

(a) Make a copy of the bibliography style file you want
to modify, say abbrvnat.bst. Call it myAbbrvnat.bst,
or whatever, and put it where tex (rather, bibtex)
will find it when processing your document. And,
of course, make sure your document specifies that
new, private, bibliography style.

(b) In your private .bst file, you should find a function
called FUNCTION {format.names}. A few lines below,
inside the function definition, you will see some
text similar to
s nameptr {f.~}{vv~}{ll}{, jj} format.name$
   ^ this controls the formatting
 of the first name. (The single
'f', for example tells bibtex to abbreviate the
first name.)

(c) Change that line to read
s nameptr {f{.}.~}{vv~}{ll}{, jj} format.name$

(d) Actually, the style you request has the last name
before the initials, so the quoted string above will
more likely read {vv~}{ll}{, jj}{, f.}, which you
would then change to read {vv~}{ll}{, jj}{, f{.}.}.

(e) Re-run bibtex, then latex. Voilà.

If you want BibDesk also to use your new .bst file, then
you will want to put it in a more central location. I
haven't tested this, but ~/Library/texmf/bibtex/bst/
should do the job. Then modify your BibDesk preferences
accordingly.

Hope this helps.

Cheers,
-Dan

PS: For *lots* more information on BibTeX, look in your
tex distribution for tamethebeast. (TeXShop's Help 
Show Help for Package ... will find it for you.)


On 1 Apr 2010, at 12:11, Josef Trapani wrote:

 Hello,
 
 Does anyone know if it is possible to format the author field of a template 
 without the space between an authors initials (when an author has two 
 initials)?
 
 When using the template modifier (for $authors): abbreviatedNormalizedName
 it yields:
 Mott, D. D., Rojas, A., Fisher, J. L., Dingledine, R. J.,
 
 Rather, I would like to have:
 Mott, D.D., Rojas, A., Fisher, J.L., Dingledine, R.J.,
 
 I know it's subtle, but some journals require this format for references,
 Joe
 --
 Download Intel#174; Parallel Studio Eval
 Try the new software tools for yourself. Speed compiling, find bugs
 proactively, and fine-tune applications for parallel performance.
 See why Intel Parallel Studio got high marks during beta.
 http://p.sf.net/sfu/intel-sw-dev
 ___
 Bibdesk-users mailing list
 Bibdesk-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/bibdesk-users


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Bibdesk-users mailing list
Bibdesk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-users


Re: [Bibdesk-users] Script hook to protect Address field

2010-04-01 Thread Christiaan Hofman

On Apr 1, 2010, at 22:15, Peter Cowan wrote:

 I'm using biblatex in the TeX preview window.  And, since I often
 import directly from ISI using the Web of Science Search function, I
 get regular errors related to commas in the address or institution
 field.  Perhaps there is a solution through biblatex to this problem,
 but I'm fine with either protecting or deleting the
 Address/Institution field on import.
 
 Script hooks seem like the perfect solution to this problem, but I am
 not an applescript users.  I've tried to cobble something together
 based on the available example and got the following which doesn't
 appear to work, on import (from Web of Science) nothing happens no
 errors no braces.  Any nudges in the right direction are appreciated.
 
 I apologize if this has been discussed on the list before, my searches
 did not reveal anything aside from confirmation of the biblatex TeX
 preview issue.
 
 Cheers
 
 Peter
 
 set protectLib to (load script file ¬
   ((path to home folder as string)  Library:Application
 Support:BibDesk:Scripts:Add Protect Strings.scpt))
 -- load the Error Reporting script library
 set errorLib to (load script file ¬
   ((path to home folder as string)  Library:ScriptingAdditions:Error
 Reporting.scpt))
 -- we only report all errors at the end
 tell errorLib
   delayReportErrors()
   set its defaultErrorFileName to BibDeskScriptErrors
 end tell
 
 property theFieldToSet : Address
 
 using terms from application BibDesk
   on perform BibDesk action with publications thePubs for script hook
 theScriptHook
   
   -- here you could return depending on theName or theField
   tell protectLib
   -- protect chars between balanced {}
   set its startProtectChar to {
   set its endProtectChar to }
   
   repeat with thePub in thePubs
   
   try
   tell thePub
   set curValue to value of field 
 theFieldToSet
   -- generate a new value for the 
 field
   set theField to field 
 theFieldToSet
   set newValue to 
 protectString(curValue)
   if newValue is not {} then ¬
   set value of theField 
 to newValue
   end tell
   
   on error errorMessage number errorNumber
   tell errorLib to 
 reportError(errorMessage, errorNumber)
   
   end try
   
   end repeat
   end tell --protectLib
   
   end perform BibDesk action with publications
 end using terms from
 
 -- see if we had any errors
 tell errorLib to checkForErrors()

This won't work, because you call the external scripts outside the perform 
BibDesk action... handler. The script hook will only call that handler, so 
anything outside it (like defining the protectLib and errorLib) will be 
ignored. Therefore reference to those external scripts will fail. You'll have 
to move everything to inside the script hook handler. 

Christiaan


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Bibdesk-users mailing list
Bibdesk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-users


Re: [Bibdesk-users] Bibdesk punctuation question

2010-04-01 Thread Christiaan Hofman
No, it's not bibtex, the question is about templates.

Anyway, it is possible, but not too easy. You'll have to format the names 
yourself using collection tags for the authors and for the initials. Replace 
$authors.abbreviatednormalizedna...@componentsjoinedbycomma/ by something 
like this:

$authors$lastName/$firstNames?, 
$firstNames$firstLetter/./$firstNames?$authors, /$authors

Christiaan

On Apr 1, 2010, at 22:14, Dan T. Abell wrote:

 Dear Joe,
 
 This is actually a BibTeX question, as it's BibTeX that
 controls the formatting of the bibliographic data. I
 haven't found a .bst file that formats as you request,
 though I'm sure one exists (if for no other reason
 than typography guru Robert Bringhurst recommends one
 put little or no space between initials).
 
 Assuming you can't get the journal to supply you with
 an appropriate bibliography style file, then here, very
 roughly, is what you need to do:
 
 (a) Make a copy of the bibliography style file you want
to modify, say abbrvnat.bst. Call it myAbbrvnat.bst,
or whatever, and put it where tex (rather, bibtex)
will find it when processing your document. And,
of course, make sure your document specifies that
new, private, bibliography style.
 
 (b) In your private .bst file, you should find a function
called FUNCTION {format.names}. A few lines below,
inside the function definition, you will see some
text similar to
s nameptr {f.~}{vv~}{ll}{, jj} format.name$
   ^ this controls the formatting
 of the first name. (The single
'f', for example tells bibtex to abbreviate the
first name.)
 
 (c) Change that line to read
s nameptr {f{.}.~}{vv~}{ll}{, jj} format.name$
 
 (d) Actually, the style you request has the last name
before the initials, so the quoted string above will
more likely read {vv~}{ll}{, jj}{, f.}, which you
would then change to read {vv~}{ll}{, jj}{, f{.}.}.
 
 (e) Re-run bibtex, then latex. Voilà.
 
 If you want BibDesk also to use your new .bst file, then
 you will want to put it in a more central location. I
 haven't tested this, but ~/Library/texmf/bibtex/bst/
 should do the job. Then modify your BibDesk preferences
 accordingly.
 
 Hope this helps.
 
 Cheers,
   -Dan
 
 PS: For *lots* more information on BibTeX, look in your
 tex distribution for tamethebeast. (TeXShop's Help 
 Show Help for Package ... will find it for you.)
 
 
 On 1 Apr 2010, at 12:11, Josef Trapani wrote:
 
 Hello,
 
 Does anyone know if it is possible to format the author field of a template 
 without the space between an authors initials (when an author has two 
 initials)?
 
 When using the template modifier (for $authors): abbreviatedNormalizedName
 it yields:
 Mott, D. D., Rojas, A., Fisher, J. L., Dingledine, R. J.,
 
 Rather, I would like to have:
 Mott, D.D., Rojas, A., Fisher, J.L., Dingledine, R.J.,
 
 I know it's subtle, but some journals require this format for references,
 Joe
 --
 Download Intel#174; Parallel Studio Eval
 Try the new software tools for yourself. Speed compiling, find bugs
 proactively, and fine-tune applications for parallel performance.
 See why Intel Parallel Studio got high marks during beta.
 http://p.sf.net/sfu/intel-sw-dev
 ___
 Bibdesk-users mailing list
 Bibdesk-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/bibdesk-users
 
 
 --
 Download Intel#174; Parallel Studio Eval
 Try the new software tools for yourself. Speed compiling, find bugs
 proactively, and fine-tune applications for parallel performance.
 See why Intel Parallel Studio got high marks during beta.
 http://p.sf.net/sfu/intel-sw-dev
 ___
 Bibdesk-users mailing list
 Bibdesk-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/bibdesk-users


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Bibdesk-users mailing list
Bibdesk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-users


Re: [Bibdesk-users] Script hook to protect Address field

2010-04-01 Thread Peter Cowan
On Thu, Apr 1, 2010 at 2:03 PM, Christiaan Hofman cmhof...@gmail.com wrote:

 On Apr 1, 2010, at 22:15, Peter Cowan wrote:

 I'm using biblatex in the TeX preview window.  And, since I often
 import directly from ISI using the Web of Science Search function, I
 get regular errors related to commas in the address or institution
 field.  Perhaps there is a solution through biblatex to this problem,
 but I'm fine with either protecting or deleting the
 Address/Institution field on import.

 Script hooks seem like the perfect solution to this problem, but I am
 not an applescript users.  I've tried to cobble something together
 based on the available example and got the following which doesn't
 appear to work, on import (from Web of Science) nothing happens no
 errors no braces.  Any nudges in the right direction are appreciated.

 I apologize if this has been discussed on the list before, my searches
 did not reveal anything aside from confirmation of the biblatex TeX
 preview issue.

 Cheers

 Peter

[snip old code]

 This won't work, because you call the external scripts outside the perform 
 BibDesk action... handler. The script hook will only call that handler, so 
 anything outside it (like defining the protectLib and errorLib) will be 
 ignored. Therefore reference to those external scripts will fail. You'll have 
 to move everything to inside the script hook handler.

Christiaan,

Thanks for the reply, I've moved the load script calls inside of the
handler, but alas it still doesn't work.  The current version is
below.

I apologize for being such an applescript newb, but is there a
workflow you follow for developing this applescripts, e.g. debugging
hints, setting breakpoints etc.

Cheers

Peter


property theFieldToSet : Address

using terms from application BibDesk
on perform BibDesk action with publications thePubs for script hook
theScriptHook

set protectLib to (load script file ¬
((path to home folder as string)  Library:Application
Support:BibDesk:Scripts:Add Protect Strings.scpt))
-- load the Error Reporting script library
set errorLib to (load script file ¬
((path to home folder as string) 
Library:ScriptingAdditions:Error Reporting.scpt))
-- we only report all errors at the end

tell errorLib
delayReportErrors()
set its defaultErrorFileName to BibDeskScriptErrors
end tell

-- here you could return depending on theName or theField
tell protectLib
-- protect chars between balanced {}
set its startProtectChar to {
set its endProtectChar to }

repeat with thePub in thePubs

try
tell thePub
set curValue to value of field 
theFieldToSet
-- generate a new value for the 
field
set theField to field 
theFieldToSet
set newValue to 
protectString(curValue)
if newValue is not {} then ¬
set value of theField 
to newValue
end tell

on error errorMessage number errorNumber
tell errorLib to 
reportError(errorMessage, errorNumber)

end try

end repeat
end tell --protectLib

end perform BibDesk action with publications
end using terms from

-- see if we had any errors
tell errorLib to checkForErrors()

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Bibdesk-users mailing list
Bibdesk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-users