 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex
 % arara: makeglossaries
 % arara: pdflatex
\documentclass{article}

\usepackage{glossaries}

\makeglossaries

\glsaddstoragekey
 {abbrtype}% key/field name
 {acronym}% default value if not explicitly set
 {\abbrtype}% custom command to access the value if required

\newacronymstyle
 {mystyle}% style name
 {% Use the generic display
   \ifglshaslong{\glslabel}{\glsgenacfmt}{\glsgenentryfmt}%
 }
 {% User needs to explicitly set the description
   \renewcommand*{\GenericAcronymFields}{}%
   % For the full format, test the value of the "abbrtype" key.
   % If it's set to "acronym" put the short form first with
   % the long form in brackets.
   \renewcommand*{\genacrfullformat}[2]{%
    \ifglsfieldeq{##1}{abbrtype}{acronym}
    {% is a proper acronym
      \protect\firstacronymfont{\glsentryshort{##1}}##2\space
       (\glsentrylong{##1})%
    }
    {% is another form of abbreviation
     \glsentrylong{##1}##2\space
      (\protect\firstacronymfont{\glsentryshort{##1}})%
    }%
  }%
  % first letter upper case version:
   \renewcommand*{\Genacrfullformat}[2]{%
    \ifglsfieldeq{##1}{abbrtype}{acronym}
    {% is a proper acronym
      \protect\firstacronymfont{\Glsentryshort{##1}}##2\space
       (\glsentrylong{##1})%
    }
    {% is another form of abbreviation
     \Glsentrylong{##1}##2\space
      (\protect\firstacronymfont{\glsentryshort{##1}})%
    }%
  }%
  % plural
   \renewcommand*{\genplacrfullformat}[2]{%
    \ifglsfieldeq{##1}{abbrtype}{acronym}
    {% is a proper acronym
      \protect\firstacronymfont{\glsentryshortpl{##1}}##2\space
       (\glsentrylong{##1})%
    }
    {% is another form of abbreviation
     \glsentrylongpl{##1}##2\space
      (\protect\firstacronymfont{\glsentryshortpl{##1}})%
    }%
  }%
  % plural and first letter upper case
  \renewcommand*{\Genplacrfullformat}[2]{%
    \ifglsfieldeq{##1}{abbrtype}{acronym}
    {% is a proper acronym
      \protect\firstacronymfont{\Glsentryshortpl{##1}}##2\space
       (\glsentrylong{##1})%
    }
    {% is another form of abbreviation
     \Glsentrylongpl{##1}##2\space
      (\protect\firstacronymfont{\glsentryshortpl{##1}})%
    }%
  }%
  % Just use the short form as the name part in the glossary:
  \renewcommand*{\acronymentry}[1]{\acronymfont{\glsentryshort{##1}}}%
  % Sort by the short form:
  \renewcommand*{\acronymsort}[2]{##1}%
  % Just use the surrounding font for the short form:
  \renewcommand*{\acronymfont}[1]{##1}%
  % Same for first use:
  \renewcommand*{\firstacronymfont}[1]{\acronymfont{##1}}%
  % Default plural suffix if the plural isn't explicitly set
  \renewcommand*{\acrpluralsuffix}{\glspluralsuffix}%
 }

\setacronymstyle{mystyle}

 % The default for "abbrtype" is "acronym" so we don't need
 % this new key for acronyms:
\newacronym[description={system for detecting the position and
speed of aircraft, ships, etc}]{radar}{radar}{radio detecting
and ranging}

\newacronym[description={device that creates a narrow beam
of intense light}]{laser}{laser}{light amplification by
stimulated emission of radiation}

\newacronym[description={portable breathing device for
divers}]{scuba}{scuba}{self-contained underwater breathing
apparatus}

\newcommand*{\newinitialism}[4][]{%
  \newacronym[abbrtype=initialism,#1]{#2}{#3}{#4}%
}

\newinitialism[description={mathematical manipulation of an
information signal}]{dsp}{DSP}{digital signal processing}
\newinitialism[description={device that allows customers of
financial institutions to perform transactions, such as
cash withdrawal, without the need for a teller}]{atm}{ATM}
{automated teller machine}

\newcommand*{\newcontraction}[4][]{%
  \newacronym[abbrtype=contraction,#1]{#2}{#3}{#4}%
}

\newcontraction[description={front part of a ship below the
deck}]{focsle}{fo'c's'le}{forecastle}

\newglossaryentry{apple}{name={apple},description={a fruit}}

\newglossarystyle
 {mystyle}% style name
 {% base it on the "list" style
   \setglossarystyle{list}%
   \renewcommand*{\glossentry}[2]{%
     \item[\glsentryitem{##1}%
          \glstarget{##1}{\glossentryname{##1}}]
       \ifglshaslong{##1}%
       { (\abbrtype{##1}: \glsentrylong{##1})\space}{}%
       \glossentrydesc{##1}\glspostdescription\space ##2}%
 }

\setglossarystyle{mystyle}

\begin{document}

First use: \gls{radar}, \gls{laser}, \gls{scuba}, \gls{dsp},
\gls{atm}, \gls{focsle}.

Next use: \gls{radar}, \gls{laser}, \gls{scuba}, \gls{dsp},
\gls{atm}, \gls{focsle}.

Regular term: \gls{apple}.

\printglossaries
\end{document}
