[bcn-pm] perltidy i comentaris
Joaquín Ferrero
explorer a joaquinferrero.com
div set 25 18:23:46 PDT 2015
El 25/09/15 a las 16:41, Diego Kuperman escribió:
> Hola!,
>
> On 25/09/15 08:51, Alba Ferrer wrote:
>>> La opción es la
>>>
>>> -bbc
>>> -blank-before-comments
>>>
>>> activa por defecto.
>> genial, gracias!
>>
>>> De todos modos, hay otra forma de hacer que perltidy "no toque" un
>>> determinado bloque de comentarios. Es la sección Static Block Comments. Por
>>> defecto es con '##', pero se puede cambiar.
>> sí, visto, pero me daba rabia lo de -bbc :-P
> Nos compartes tu .perltidyrc ? :-)
>
Ahí va el mío.
He puesto algunos comentarios en algunos de ellos, por temas de incompatibilidades con otras opciones (por ejemplo, -b es incompatible con -bpb).
Cuidado, porque a veces hay que buscarle el truco a las opciones -b y -nst: si llamamos a perltidy como un filtro externo desde nuestro editor, no es necesario que nos cree un .bak, así que es mejor desactivar la opción -b. Y la -nst va según cómo trabaje nuestro editor a la hora de pasar a Perltidy un bloque o todo el código (usando STDOUT o un archivo temporal).
También hay algunas cosas personales, como por ejemplo, desactivar /Static Blocks Comments/, porque a veces sí que uso '##' para otras cosas, y sí quiero que sean formateados como el resto de comentarios.
Hay cosas curiosas que se han ido acumulando con los años: -wbb define los operadores por los que se puede "romper la línea", pero en las nuevas versiones de Perltidy apareció la opción -bbao, con lo que engloba a todos los operadores, y ya no es necesario ponerlos todos en -wbb. O la longitud de la línea, que hace mucho que lo pasé de 80 a 120 columnas.
Al menos, esta es la configuración que mejor me funciona con editores en terminal, como puede ser el joe y Eclipse (con e-p-i-c). Ahora es tarde, pero mañana veo qué tal va con vim.
#------
#------ A .perltidyrc configuration file for the nice tool Perltidy
#------ You found it at www.leifove.com.
#------ Note! Because of the -b option used below, the original Perl file
#------ is backed up by Perltidy, and the original then tidyied.
#------ See CPAN. org for more info about where to store this file and
#------ how to call Perltidy on your source code files.
#------
#---------------- PBP options, as listed on page 35 of PBP ----------------
-pbp # equivale a:
-l=120 # Max line width is 78 cols
#-i=4 # Indent level is 4 cols
#-ci=4 # Continuation indent is 4 cols
#-st # Salida por la standard-output
#-se # Salida por la standard-error
#-vt=2 # Maximal vertical tightness
#-cti=0 # No extra indentation for closing brackets
#-pt=1 # Medium parenthesis tightness
#-bt=1 # Medium brace tightness (for non-code blocks)
#-sbt=1 # Medium square bracket tightness
#-bbt=1 # Medium block brace tightness (for code blocks)
#-nsfs # No space before semicolons
#-nolq # Don't outdent long quoted strings
# Break before all operators:
#-wbb="% + - * / x != == >= <= =~ !~ < > | & = // **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x="
-bbao # --break-before-all-operators.
# Note that the PBP book has a typo on page 35 when defining the above -wbb
# option, see http://oreilly.com/catalog/perlbp/errata/perlbp.confirmed
# The above string is correct.
#---------- Perltidy default options (i.e. in line with PBP) --------------
-asc # Add any missing optional semicolon at the end of a line
-aws # Add certain whitespace to improve code readability
-tqw # Default handling of multi-line 'qw' quotes
-ibc # Indent block comments to same level as the code
-msc=4 # Minimum 4 spaces between code and same-line comments
-fpsc=48 # Don't try to line up all comments to a fixed column
-hsc # Align hanging side comments
#-sbcp='^#{2,}[^\s#]' # Enable static block comments
-nssc # No special handling for static side comments
-dnl # Delete old newlines
-bbc # Ensure a blank line before every full-line comment
-bbs # Ensure a blank line before every sub definition (except one-liners)
-bbb # Ensure a blank line before code blocks (for, while, if, ....)
-lbl=8 # Minimum number of lines between each -bbb inserted blank line
#------------- Additional options, based on PBP recommendations ------------
-bar # K&R style code braces
-nolc # Long comments indented, even when this make the total line length "too long"
-noll # Long lines indented, even when this make the total line length "too long"
-nola # Don't treat labels as special cases when indenting
#---------- Options concerning Perltidy's input and ouput files -----------
-nst # Do NOT output to STDOUT (since we want to use -b)
#-b # Backup the input file to .bak and perform all tidying in the original file. No se puede usar con -pbp
#-se # Write errors to STDERR. Activado con -pbp
-ple # Preserve the EOL character(s). E.g. in case Perltidy runs
# on Windows, but processes a Perl file for Unix (and vice versa)
#----------- Some other Perltidy options, intentionally not used ----------
# The following Perltidy options are NOT consistent with PBP and should NOT be used:
# -lp, -icb, -fws, -nwls, -nwrs, -sfp, -sak/-nsak, -csc/dcsc, -fnl,
# -ce, -bl, -sbl, -bli, -blil, -bbvt, -otr, -sct, -boc, -kis,
# -pbp (because the -wbb list typo in the PBP book carried over to Perltidy (!))
# The following Perltidy options are not used, for other reasons:
# -sot, -mft, -cab, -bol, -bok/-nbok, -bot/-nbot, -iob, -isbc
------------ pr�a parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://mail.pm.org/pipermail/barcelona-pm/attachments/20150926/5c31d530/attachment.html>
Més informació sobre la llista de correu Barcelona-pm