% The rules below clean up and shorten bibliography entries according to my
% personal perferences.

% 1. don't show various fields such as ISBNs, etc.
%
\AtEveryBibitem{\clearfield{doi}}
\AtEveryBibitem{\clearfield{eprint}}
\AtEveryBibitem{\clearfield{isbn}}
\AtEveryBibitem{\clearfield{issn}}
\AtEveryBibitem{\clearfield{pagetotal}}
\AtEveryBibitem{\clearfield{series}}
\AtEveryBibitem{\ifboolexpr{test {\ifentrytype{electronic}} or
                            test {\ifentrytype{online}} or
                            test {\ifentrytype{misc}}}{}{\clearfield{url}}}
\AtEveryBibitem{\clearlist{language}}
\AtEveryBibitem{\clearlist{publisher}}
\AtEveryBibitem{\clearname{editor}}
\AtEveryBibitem{\ifentrytype{article}{\clearfield{number}}{}}
\AtEveryBibitem{\ifentrytype{inproceedings}{\clearfield{volume}}{}}

\DeclareFieldFormat{url}{\url{#1}}

\usepackage{xpatch}

\xpatchbibdriver{online}
  {\printtext[parens]{\usebibmacro{date}}}
  {\iffieldundef{year}
    {}
    {\printtext[parens]{\usebibmacro{date}}}}
  {}
  {\typeout{There was an error patching biblatex-ieee (specifically, ieee.bbx's @online driver)}}

% \AtEveryBibitem{\clearfield{month}}
% \AtEveryBibitem{\clearfield{note}}
% \AtEveryBibitem{\clearfield{pages}}
% \AtEveryBibitem{\clearlist{institution}}
% \AtEveryBibitem{\clearlist{location}}

\AtEveryCitekey{\UseBibitemHook}


% 2. shorten various conference and journal titles to some sane length
%
\DeclareSourcemap{
        \maps[datatype=bibtex]{
                \map{
                        % shorten conferences
                        \step[fieldsource=booktitle,
                                match={.*Internet Measurement Conference.*},
                                replace={ACM IMC}]
                        \step[fieldsource=booktitle,
                                match={.*Networked Systems Design and Implementation.*},
                                replace={USENIX NSDI}]
                        \step[fieldsource=booktitle,
                                match={.*Hot Topics in Networks.*},
                                replace={ACM HotNets}]
                        \step[fieldsource=booktitle,
                                match={.*Ope..ting Systems Design .* Implementation.*},
                                replace={USENIX OSDI}]
                        \step[fieldsource=booktitle,
                                match={.*USENIX.*Annual Technical Conference.*},
                                replace={USENIX ATC}]
                        \step[fieldsource=booktitle,
                                match={.*Conference on File and Storage Technologies.*},
                                replace={USENIX FAST}]
                        \step[fieldsource=booktitle,
                                match={.*European Conference on Computer Systems.*},
                                replace={ACM EuroSys}]
                        \step[fieldsource=booktitle,
                                match={.*Symposium on Operating Systems Principles.*},
                                replace={ACM SOSP}]
                        \step[fieldsource=booktitle,
                                match={.*(USENIX Security Symposium|USENIX Conference on Security).*},
                                replace={USENIX Security}]
                        \step[fieldsource=booktitle,
                                match={.*USENIX Symposium on Internet Technologies and Systems.*},
                                replace={USENIX USITS}]
                        \step[fieldsource=booktitle,
                                match={.*Emerging Networking E.periments .nd Technologies.*},
                                replace={ACM CoNEXT}]
                        \step[fieldsource=booktitle,
                                match={.*INFOCOM.*},
                                replace={IEEE Infocom}]
                        \step[fieldsource=booktitle,
                                match={.*Mobile Computing and Networking.*},
                                replace={ACM MobiCom}]
                        \step[fieldsource=booktitle,
                                match={.*Roedunet.*},
                                replace={IEEE RoEduNet}]
                        \step[fieldsource=booktitle,
                                match={.*Symposium on Software Defined Networking Research.*},
                                replace={ACM SOSR}]
                        \step[fieldsource=booktitle,
                                match={.*Architectures? for Networking and Communications Systems.*},
                                replace={ACM ANCS}]
                        \step[fieldsource=booktitle,
                                match={.*QoS.*Mini.*Conf.*ICC.*},
                                replace={IEEE ICC QoS Mini-Conference}]
                        \step[fieldsource=institution,
                                match={.*Barcelona Supercomputing Center.*},
                                replace={Barcelona Supercomputing Center (BSC)}]
                        \step[fieldsource=booktitle,
                                match={.*System Administration and Network Engineering Conference.*},
                                replace={SANE}]
                        \step[fieldsource=booktitle,
                                match={.*Architectural Support for Programming Languages and Operating Systems.*},
                                replace={ACM ASPLOS}]
                        \step[fieldsource=booktitle,
                                match={.*Passive and Active Measurement.*},
                                replace={PAM}]
                        \step[fieldsource=booktitle,
                                match={.*E2EMON.*},
                                replace={IEEE/IFIP E2EMON}]
                        \step[fieldsource=booktitle,
                                match={.*International Conference on Autonomic Computing.*},
                                replace={IEEE ICAC}]
                        \step[fieldsource=booktitle,
                                match={.*Hot Topics in Middleboxes.*},
                                replace={ACM SIGCOMM HotMiddlebox}]
                        \step[fieldsource=booktitle,
                                match={.*Hot Topics in Management of Internet, Cloud, and Enterprise Networks.*},
                                replace={USENIX Hot-ICE}]
                        \step[fieldsource=booktitle,
                                match={.*International (ACM )?Conference on Supercomputing.*},
                                replace={ACM ICS}]
                        \step[fieldsource=booktitle,
                                match={.*Symposium on Mass Storage Systems and Technolog.*},
                                replace={MSST}]
                        \step[fieldsource=booktitle,
                                match={.*International Symposium on Microarchitecture.*},
                                replace={IEEE/ACM MICRO}]
                        \step[fieldsource=booktitle,
                                match={.*Languages and Compilers for Parallel Computing.*},
                                replace={LCPC}]
                        \step[fieldsource=booktitle,
                                match={.*Conference for High Performance Computing, Networking, Storage and Analysis.*},
                                replace={ACM/IEEE SC}]
                        \step[fieldsource=booktitle,
                                match={.*International Symposium on Computing and Networking.*},
                                replace={CANDAR}]
                        \step[fieldsource=booktitle,
                                match={.*Euro-Par.*},
                                replace={Euro-Par}]
                        \step[fieldsource=booktitle,
                                match={.*Symposium on High-Performance Interconnects.*},
                                replace={IEEE Hot Interconnects}]
                        \step[fieldsource=booktitle,
                                match={.*Conference on Microelectronic Systems Education.*},
                                replace={IEEE MSE}]
                        \step[fieldsource=booktitle,
                                match={.*International Conference on Big Data.*},
                                replace={IEEE Big Data}]
                        \step[fieldsource=booktitle,
                                match={.*Symposium on Modeling, Analysis, and Simulation.*},
                                replace={IEEE MASCOTS}]
                        \step[fieldsource=booktitle,
                                match={.*Euromicro Conference on Digital System Design.*},
                                replace={Euromicro DSD}]
                        \step[fieldsource=booktitle,
                                match={.*USENIX Winter Conference.*},
                                replace={USENIX Winter}]
                        \step[fieldsource=booktitle,
                                match={.*SIGMETRICS.*},
                                replace={ACM SIGMETRICS}]
                        \step[fieldsource=booktitle,
                                match={.*Systems and Storage Conference.*},
                                replace={ACM SYSTOR}]
                        \step[fieldsource=booktitle,
                                match={.*Joint Meeting of the European Software Engineering Conference and the ACM SIGSOFT Symposium on the Foundations of Software Engineering.*},
                                replace={ESEC/FSE}]
                        \step[fieldsource=booktitle,
                                match={.*Hot Topics in Cloud Computing.*},
                                replace={USENIX HotCloud}]
                        \step[fieldsource=booktitle,
                                match={.*Mass Storage Systems and Technologies.*},
                                replace={MSST}]
                        \step[fieldsource=booktitle,
                                match={.*International Conference on Management of Data.*},
                                replace={ACM SIGMOD}]
                        \step[fieldsource=booktitle,
                                match={.*Workshop on Performance Analysis of Workload Optimized Systems.*},
                                replace={FastPath Workshop}]
                        \step[fieldsource=booktitle,
                                match={.*Multimedia Systems Conference.*},
                                replace={ACM MMSys}]
                        \step[fieldsource=booktitle,
                                match={.*IFIP Networking Conference.*},
                                replace={IFIP Networking}]
                        \step[fieldsource=booktitle,
                                match={.*Conference on Local Computer Networks.*},
                                replace={IEEE LCN}]
                        \step[fieldsource=booktitle,
                                match={.*International Packet Video Workshop.*},
                                replace={Packet Video Workshop}]
                        \step[fieldsource=booktitle,
                                match={.*Evolution, Performance, and Interoperability of QUIC.*},
                                replace={ACM EPIQ}]
                        \step[fieldsource=booktitle,
                                match={.*International Conference on World Wide Web.*},
                                replace={WWW}]
                        \step[fieldsource=booktitle,
                                match={.*Security Standardisation Research.*},
                                replace={SSR}]
                        \step[fieldsource=booktitle,
                                match={.*Symposium on Security and Privacy.*},
                                replace={IEEE SSP}]
                        \step[fieldsource=booktitle,
                                match={.*Network and Operating Systems Support for Digital Audio and Video.*},
                                replace={ACM NOSSDAV}]
                        % keep this last
                        \step[fieldsource=booktitle,
                                match={.*(Conference on SIGCOMM|Special Interest Group on Data Communication|Applications, Technologies, Architectures, and Protocols|Communications Architectures and Protocols).*},
                                replace={ACM SIGCOMM}]
                        % shorten journals
                        \step[fieldsource=journal,
                                match={.*IEEE Journal on Selected Areas in Communication.*},
                                replace={IEEE JSAC}]
                        \step[fieldsource=journal,
                                match={.*Trans. Netw..*},
                                replace={IEEE/ACM ToN}]
                        \step[fieldsource=journal,
                                match={.*Transactions on Network and Service Management*},
                                replace={IEEE ToNSM}]
                        \step[fieldsource=journal,
                                match={.*Comput. Commun. Rev..*},
                                replace={ACM SIGCOMM CCR}]
                }
        }
}


% 3. Use "Proc." for @inproceedings (not "In:") and abbreviate months consistently
%
\DeclareLanguageMapping{american}{bib/lars-american}
\DeclareLanguageMapping{british}{bib/lars-british}
\DeclareLanguageMapping{english}{bib/lars-english}

