[Bibdesk-users] Length of acronym when generating a citekey

2021-03-17 Thread Mahmood Shafeie Zargar
Dear Christiaan and The BibDesk Community,

I would like to make a citekey generator format that for the following entry:

@article{xxx,
author = {Slaughter, Andrew J and Koehly, Laura M},
journal = {Social networks},
pages = {334--345},
title = {Multilevel models for social networks: Hierarchical Bayesian 
approaches to exponential random graph modeling},
volume = {44},
year = {2016}}

yields Slaughter2016mms. That is, First Author + Year + 3 First Letters of the 
Acronym.

I have tried %p1%Y%c{Title}3, and BibDesk does accept 3 as a parameter for %c, 
but that has no effect. Why does acronym take a number parameter, and what can 
it mean, other than the number of letters (number of words doesn't make any 
sense for an acronym that is by default one word only).

Also, is there any way to transform acronyms into lower case?


Thanks!
Mahmood
___
Bibdesk-users mailing list
Bibdesk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-users


Re: [Bibdesk-users] Feature request: remove file on disk when removing link

2020-06-12 Thread Mahmood Shafeie Zargar
Yes, I just noticed after your email. Great addition!

Thanks,
Mahmood

> On 12 Jun 2020, at 17:02, Christiaan Hofman  wrote:
> 
> BibDesk should be able to already do this for you.
> 
> Christiaan
> 
>> On 12 Jun 2020, at 11:19, Mahmood Shafeie Zargar  wrote:
>> 
>> Hi Luc,
>> 
>> I agree it would be great if BibDesk could at least give us the option.
>> 
>> BibDesk already has an Orphaned Files feature that you can use periodically 
>> to remove the files you don't need anymore from your attachments directory.
>> 
>> Otherwise, I use the following script with the Remove File hook to do just 
>> what you desire:
>> 
>> using terms from application "BibDesk"
>> on perform BibDesk action with publications thePubs for script hook 
>> theScriptHook
>> tell application "BibDesk"
>> set theField to get field name of theScriptHook
>> set oldValues to get old values of theScriptHook
>> if theField = "Local File" then
>> repeat with theFile in oldValues
>> set theAlertText to "File association removed."
>> set theAlertMessage to "You are detaching the file \"" & 
>> theFile & "\" from the corresponding publication. Would you like to delete 
>> the file from the file system as well?"
>> set result to display alert theAlertText message 
>> theAlertMessage as critical buttons {"Keep", "Remove"} default button 
>> "Remove" cancel button "Keep"
>> if button returned of result = "Remove" then
>> tell application "Finder" to delete theFile as POSIX 
>> file
>> end if
>> end repeat
>> end if
>> end tell
>> end perform BibDesk action with publications
>> end using terms from
>> 
>> 
>> Hope this helps,
>> Mahmood
>> On 12 Jun 2020, 11:05 +0200, Fischlin Andreas 
>> , wrote:
>>> Dear Luc,
>>> 
>>> Indeed, that would be annoying.
>>> 
>>> BTW, I offer on my website several AppleScripts which greatly support such 
>>> tasks. E.g. I can simply replace in the Finder an obsolete version of a PDF 
>>> with an updated one and then trigger with a shortcut (Ctrl^F) an 
>>> AppleScript that discards the old link and replaces it with a new link to 
>>> the new file. There is only one drawback for this to work, I use 
>>> information from the record to construct the file name. In my case I use 
>>> only the cite key with some suffixes if there are several PDF’s linked to 
>>> the same article, e.g. supplementary material, to name my PDFs.
>>> 
>>> Should you be interested, here the link: 
>>> https://www.sysecol2.ethz.ch/software/
>>> 
>>> Regards, 
>>> Andreas 
>>> 
>>> ETH Zurich
>>> Prof. em. Dr. Andreas Fischlin
>>> IPCC Vice-Chair WGII
>>> Systems Ecology - Institute of Biogeochemistry and Pollutant Dynamics
>>> CHN E 24
>>> Universitaetstrasse 16
>>> 8092 Zurich
>>> SWITZERLAND
>>> 
>>> andreas.fisch...@env.ethz.ch
>>> www.sysecol.ethz.ch/people/andreas.fischlin.hml
>>> 
>>> +41 44 633-6090 phone
>>> +41 44 633-1136 fax
>>> +41 79 595-4050 mobile
>>> 
>>>  Make it as simple as possible, but distrust it!
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>>> On 12/06/2020, at 09:31, Luc Bourhis via Bibdesk-users 
>>>>  wrote:
>>>> 
>>>> Hi,
>>>> 
>>>> it would be sweet if BibDesk would propose to remove the actual file on 
>>>> disk when one removes a link from a record. It happens every now and then 
>>>> that either I filed the wrong file, or more often that I want to replace a 
>>>> preprint by a later version or the published one. Currently, I have to 
>>>> remove the link, add the new one, then use “Reveal in Finder” and remove 
>>>> the old one. A bit tedious.
>>>> 
>>>> Best wishes,
>>>> 
>>>> Luc J Bourhis
>>>> 
> 
> ___
> Bibdesk-users mailing list
> Bibdesk-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bibdesk-users



___
Bibdesk-users mailing list
Bibdesk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-users


Re: [Bibdesk-users] Feature request: remove file on disk when removing link

2020-06-12 Thread Mahmood Shafeie Zargar
Hi Luc,

I agree it would be great if BibDesk could at least give us the option.

BibDesk already has an Orphaned Files feature that you can use periodically to 
remove the files you don't need anymore from your attachments directory.

Otherwise, I use the following script with the Remove File hook to do just what 
you desire:

using terms from application "BibDesk"
    on perform BibDesk action with publications thePubs for script hook 
theScriptHook
        tell application "BibDesk"
            set theField to get field name of theScriptHook
            set oldValues to get old values of theScriptHook
            if theField = "Local File" then
                repeat with theFile in oldValues
                    set theAlertText to "File association removed."
                    set theAlertMessage to "You are detaching the file \"" & 
theFile & "\" from the corresponding publication. Would you like to delete the 
file from the file system as well?"
                    set result to display alert theAlertText message 
theAlertMessage as critical buttons {"Keep", "Remove"} default button "Remove" 
cancel button "Keep"
                    if button returned of result = "Remove" then
                        tell application "Finder" to delete theFile as POSIX 
file
                    end if
                end repeat
            end if
        end tell
    end perform BibDesk action with publications
end using terms from


Hope this helps,
Mahmood
On 12 Jun 2020, 11:05 +0200, Fischlin Andreas , 
wrote:
> Dear Luc,
>
> Indeed, that would be annoying.
>
> BTW, I offer on my website several AppleScripts which greatly support such 
> tasks. E.g. I can simply replace in the Finder an obsolete version of a PDF 
> with an updated one and then trigger with a shortcut (Ctrl^F) an AppleScript 
> that discards the old link and replaces it with a new link to the new file. 
> There is only one drawback for this to work, I use information from the 
> record to construct the file name. In my case I use only the cite key with 
> some suffixes if there are several PDF’s linked to the same article, e.g. 
> supplementary material, to name my PDFs.
>
> Should you be interested, here the link: 
> https://www.sysecol2.ethz.ch/software/
>
> Regards,
> Andreas
>
> ETH Zurich
> Prof. em. Dr. Andreas Fischlin
> IPCC Vice-Chair WGII
> Systems Ecology - Institute of Biogeochemistry and Pollutant Dynamics
> CHN E 24
> Universitaetstrasse 16
> 8092 Zurich
> SWITZERLAND
>
> andreas.fisch...@env.ethz.ch
> www.sysecol.ethz.ch/people/andreas.fischlin.hml
>
> +41 44 633-6090 phone
> +41 44 633-1136 fax
> +41 79 595-4050 mobile
>
>              Make it as simple as possible, but distrust it!
> 
>
>
>
>
>
>
> > On 12/06/2020, at 09:31, Luc Bourhis via Bibdesk-users 
> >  wrote:
> >
> > Hi,
> >
> > it would be sweet if BibDesk would propose to remove the actual file on 
> > disk when one removes a link from a record. It happens every now and then 
> > that either I filed the wrong file, or more often that I want to replace a 
> > preprint by a later version or the published one. Currently, I have to 
> > remove the link, add the new one, then use “Reveal in Finder” and remove 
> > the old one. A bit tedious.
> >
> > Best wishes,
> >
> > Luc J Bourhis
> >
> >
> >
> > ___
> > Bibdesk-users mailing list
> > Bibdesk-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/bibdesk-users
>
> ___
> Bibdesk-users mailing list
> Bibdesk-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bibdesk-users
___
Bibdesk-users mailing list
Bibdesk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-users


Re: [Bibdesk-users] JXA ScriptHook

2019-05-03 Thread Mahmood Shafeie Zargar
That sample script has a problem in the for loop, as well as in fetching the 
property value. That still doesn't work for me.

But this one works:


function performBibDeskActionWithPublications(thePubs, {forScriptHook : 
theScriptHook }) {

var theName = theScriptHook.name();

var theID = theScriptHook.id();

var theField = theScriptHook.fieldName();

var oldValues = theScriptHook.oldValues();

var newValues = theScriptHook.newValues();

var theKeys = [];

var theTitles = [];


for (var i=0, aPub; aPub=thePubs[i]; i++) {

theKeys.push(aPub.citeKey());

theTitles.push(aPub.fields.byName("Author").value());

}


var app = Application.currentApplication();

app.includeStandardAdditions = true;


app.displayDialog("Name: " + theName + "\n" + "ID: " + theID + "\n" + "Cite 
Keys: " + theKeys + "\n"  + "Titles: " + theTitles + "\n" + "Field name: " + 
theField + "\n" + "Old values: " + oldValues + "\n" + "New values: " + 
newValues, { buttons :["OK"], defaultButton : 1 });

}


Best,
Mah


From: Christiaan Hofman 
Sent: May 2, 2019 7:22 PM
To: For general discussion about using BibDesk
Subject: Re: [Bibdesk-users] JXA ScriptHook



On 2 May 2019, at 18:55, Christiaan Hofman 
mailto:cmhof...@gmail.com>> wrote:



On 2 May 2019, at 18:12, Christiaan Hofman 
mailto:cmhof...@gmail.com>> wrote:



On 2 May 2019, at 17:22, Mahmood Shafeie Zargar 
mailto:m...@msn.com>> wrote:

Hi,

I would like to know where I can find an example of a script hook written in 
JavaScript.

I have tried things like this to no avail:

functionperformBibDeskActionWithPublications(pubs, scriptHook) {

}

The function code runs, but no value is loaded in the parameters.

Thanks,
Mah

I haven’t tried using JXA script hooks, but I think they should work. Though it 
could be JXA hangs BibDesk, because of bugs with JXA (that Apple says aren’t 
bugs but just how it works), that will be fixed in the next release.

I am not an expert on JS, but shouldn’t it be:

function performBibDeskActionWithPublications(pubs, {forScriptHook:scriptHook}) 
{
}

Christiaan

Here is the JXA version for the sample script hook:

function performBibDeskActionWithPublications(thePubs, { forScriptHook : 
theScriptHook }) {
var theName = theScriptHook.name();
var theID = theScriptHook.id<http://thescripthook.id/>();
var theField = theScriptHook.fieldName();
var oldValues = theScriptHook.oldValues();
var newValues = theScriptHook.newValues();
var theKeys = [];
for (var aPub in thePubs) {
theKeys.push(aPub.citeKey);
}
var app = Application.currentApplication();
app.includeStandardAdditions = true;
app.displayDialog("Name: " + theName + "\n" + "ID: " + theID + "\n" + "Cite 
Keys: " + theKeys + "\n" + "Field name: " + theField + "\n" + "Old values: " + 
oldValues + "\n" + "New values: " + newValues, { buttons : ["OK"], 
defaultButton : 1 });
}

It works for me, at least with the current nightly.

Christiaan


I’ve added some sample JXA script hooks on the Wiki.

Christiaan

___
Bibdesk-users mailing list
Bibdesk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-users


Re: [Bibdesk-users] JXA ScriptHook

2019-05-03 Thread Mahmood Shafeie Zargar
Sorry for spamming. No worries, I found them. The link is on the top of the 
front page!

From: Mahmood Shafeie Zargar 
Sent: May 3, 2019 12:20 AM
To: For general discussion about using BibDesk
Subject: Re: [Bibdesk-users] JXA ScriptHook

Thanks! Very useful.

It definitely doesn't work here (1.6.22 (4794)).

Where can I get the nightly?

Best wishes,
Mah

From: Christiaan Hofman 
Sent: May 2, 2019 7:22 PM
To: For general discussion about using BibDesk
Subject: Re: [Bibdesk-users] JXA ScriptHook



On 2 May 2019, at 18:55, Christiaan Hofman 
mailto:cmhof...@gmail.com>> wrote:



On 2 May 2019, at 18:12, Christiaan Hofman 
mailto:cmhof...@gmail.com>> wrote:



On 2 May 2019, at 17:22, Mahmood Shafeie Zargar 
mailto:m...@msn.com>> wrote:

Hi,

I would like to know where I can find an example of a script hook written in 
JavaScript.

I have tried things like this to no avail:

functionperformBibDeskActionWithPublications(pubs, scriptHook) {

}

The function code runs, but no value is loaded in the parameters.

Thanks,
Mah

I haven’t tried using JXA script hooks, but I think they should work. Though it 
could be JXA hangs BibDesk, because of bugs with JXA (that Apple says aren’t 
bugs but just how it works), that will be fixed in the next release.

I am not an expert on JS, but shouldn’t it be:

function performBibDeskActionWithPublications(pubs, {forScriptHook:scriptHook}) 
{
}

Christiaan

Here is the JXA version for the sample script hook:

function performBibDeskActionWithPublications(thePubs, { forScriptHook : 
theScriptHook }) {
var theName = theScriptHook.name();
var theID = theScriptHook.id<http://thescripthook.id/>();
var theField = theScriptHook.fieldName();
var oldValues = theScriptHook.oldValues();
var newValues = theScriptHook.newValues();
var theKeys = [];
for (var aPub in thePubs) {
theKeys.push(aPub.citeKey);
}
var app = Application.currentApplication();
app.includeStandardAdditions = true;
app.displayDialog("Name: " + theName + "\n" + "ID: " + theID + "\n" + "Cite 
Keys: " + theKeys + "\n" + "Field name: " + theField + "\n" + "Old values: " + 
oldValues + "\n" + "New values: " + newValues, { buttons : ["OK"], 
defaultButton : 1 });
}

It works for me, at least with the current nightly.

Christiaan


I’ve added some sample JXA script hooks on the Wiki.

Christiaan

___
Bibdesk-users mailing list
Bibdesk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-users


[Bibdesk-users] JXA ScriptHook

2019-05-02 Thread Mahmood Shafeie Zargar
Hi,

I would like to know where I can find an example of a script hook written in 
JavaScript.

I have tried things like this to no avail:


functionperformBibDeskActionWithPublications(pubs, scriptHook) {


}


The function code runs, but no value is loaded in the parameters.


Thanks,

Mah

___
Bibdesk-users mailing list
Bibdesk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-users