{"thread":{"id":"24497","subject":"[PATCH] gitweb: move highlight config out of guess_file_syntax()","startedAt":"2010-07-24T19:46:07Z","lastAt":"2010-07-28T18:40:53Z","messageCount":6,"participants":["Alejandro R. Sedeño","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"146203","messageId":"1280000767-31895-1-git-send-email-asedeno@mit.edu","threadId":"24497","inReplyTo":null,"subject":"[PATCH] gitweb: move highlight config out of guess_file_syntax()","fromName":"Alejandro R. Sedeño","fromEmail":"asedeno@mit.edu","sentAt":"2010-07-24T19:46:07Z","receivedAt":"2010-07-24T19:46:07Z","isPatch":true,"sender":{"key":"asedeno@mit.edu","avatar":"https://avatars.githubusercontent.com/u/28302?v=4"},"body":"Move highlight config out of guess_file_syntax() so that it can be\nextended/overridden by system/user configuration.\n\nSigned-off-by: Alejandro R. Sedeño <asedeno@mit.edu>\n---\n gitweb/gitweb.perl |   47 +++++++++++++++++++++++------------------------\n 1 files changed, 23 insertions(+), 24 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex cedc357..e0e9532 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -232,6 +232,29 @@ our %avatar_size = (\n # Leave it undefined (or set to 'undef') to turn off load checking.\n our $maxload = 300;\n \n+# configuration for 'highlight' (http://www.andre-simon.de/)\n+# match by basename\n+our %highlight_basename = (\n+\t#'Program' => 'py',\n+\t#'Library' => 'py',\n+\t'SConstruct' => 'py', # SCons equivalent of Makefile\n+\t'Makefile' => 'make',\n+);\n+# match by extension\n+our %highlight_ext = (\n+\t# main extensions, defining name of syntax;\n+\t# see files in /usr/share/highlight/langDefs/ directory\n+\tmap { $_ => $_ }\n+\t\tqw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl),\n+\t# alternate extensions, see /etc/highlight/filetypes.conf\n+\t'h' => 'c',\n+\tmap { $_ => 'cpp' } qw(cxx c++ cc),\n+\tmap { $_ => 'php' } qw(php3 php4),\n+\tmap { $_ => 'pl'  } qw(perl pm), # perhaps also 'cgi'\n+\t'mak' => 'make',\n+\tmap { $_ => 'xml' } qw(xhtml html htm),\n+);\n+\n # You define site-wide feature defaults here; override them with\n # $GITWEB_CONFIG as necessary.\n our %feature = (\n@@ -3316,30 +3339,6 @@ sub blob_contenttype {\n sub guess_file_syntax {\n \tmy ($highlight, $mimetype, $file_name) = @_;\n \treturn undef unless ($highlight && defined $file_name);\n-\n-\t# configuration for 'highlight' (http://www.andre-simon.de/)\n-\t# match by basename\n-\tmy %highlight_basename = (\n-\t\t#'Program' => 'py',\n-\t\t#'Library' => 'py',\n-\t\t'SConstruct' => 'py', # SCons equivalent of Makefile\n-\t\t'Makefile' => 'make',\n-\t);\n-\t# match by extension\n-\tmy %highlight_ext = (\n-\t\t# main extensions, defining name of syntax;\n-\t\t# see files in /usr/share/highlight/langDefs/ directory\n-\t\tmap { $_ => $_ }\n-\t\t\tqw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl),\n-\t\t# alternate extensions, see /etc/highlight/filetypes.conf\n-\t\t'h' => 'c',\n-\t\tmap { $_ => 'cpp' } qw(cxx c++ cc),\n-\t\tmap { $_ => 'php' } qw(php3 php4),\n-\t\tmap { $_ => 'pl'  } qw(perl pm), # perhaps also 'cgi'\n-\t\t'mak' => 'make',\n-\t\tmap { $_ => 'xml' } qw(xhtml html htm),\n-\t);\n-\n \tmy $basename = basename($file_name, '.in');\n \treturn $highlight_basename{$basename}\n \t\tif exists $highlight_basename{$basename};\n-- \n1.7.2\n"},{"id":"146335","messageId":"4C4CCE60.1080301@mit.edu","threadId":"24497","inReplyTo":"201007260135.35059.jnareb@gmail.com","subject":"Re: [PATCH] gitweb: move highlight config out of guess_file_syntax()","fromName":"Alejandro R. Sedeño","fromEmail":"asedeno@mit.edu","sentAt":"2010-07-25T23:53:04Z","receivedAt":"2010-07-25T23:53:04Z","isPatch":true,"sender":{"key":"asedeno@mit.edu","avatar":"https://avatars.githubusercontent.com/u/28302?v=4"},"body":"On 7/25/2010 7:35 PM, Jakub Narebski wrote:\n> BTW. is this something _you_ needed (and what did you need to configure\n> / to put in $GITWEB_CONFIG file), or just a generalization?\n\n\nThis is something I was using in previous versions of gitweb, though\nwith the older (pre-592ea41) syntax. (I had applied the older\nhighlighting patches, and was quite happy to see them merged.)\n\nBefore, $GITWEB_CONFIG contained lines like:\n\n  $highlight_type{'\\.lisp$'} = 'lisp';\n\nAs of 1.7.2, with syntax highlighting merged and refactored (592ea41),\naccess to the hashes that define syntax highlighting mappings was lost.\nMoving the hashes out into the config area lets $GITWEB_CONFIG contain\nlines like:\n\n  $highlight_ext{'lisp'} = 'lisp';\n  $highlight_basename{'GNUmakefile'} = 'mak'\n"},{"id":"146430","messageId":"201007262245.35518.jnareb@gmail.com","threadId":"24497","inReplyTo":"201007260135.35059.jnareb@gmail.com","subject":"Re: [PATCH] gitweb: move highlight config out of guess_file_syntax()","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-07-26T20:45:32Z","receivedAt":"2010-07-26T20:45:32Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Mon, 26 Jul 2010, Jakub Narębski wrote:\n> On Sat, 24 Jul 2010, Alejandro R. Sedeño wrote:\n> \n> > Move highlight config out of guess_file_syntax() so that it can be\n> > extended/overridden by system/user configuration.\n> > \n> > Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>\n> \n> Good idea.\n> \n> The only _possible_ problem is that this configuration is fairly specific\n> with respect to currently the only one sipported hightlighter, i.e. the\n> external binary 'highlight' (http://www.andre-simon.de).  If we are to\n> add support for other programs (e.g. GNU Source Highlight) or Perl modules\n> for syntax highlighting (e.g. Syntax::Highlight::Engine::Kate or \n> Beautifier) in the future, this could mean backward incompatibile change.\n> \n> The culprit is using extensions (in 'highlight' main syntax files are \n> named by extensions) rather than format names in %highlight_basename\n> and %highlight_ext, e.g. 'py' rather than 'python'.  I don't know if\n> it would be much of the problem.\n> \n> So perhaps I am worrying about nothing...\n\nI am worrying about nothing.  The default syntax highlighter would be\n'highlight' program; if one wants to change highlighter, one can also\nmodify required configuration (names of 'syntax' to choose from might\nbe different for different highlighting engines).\n\nTherefore:\n\nAcked-by: Jakub Narebski <jnareb@gmail.com>\n\n-- \nJakub Narebski\nPoland\n"},{"id":"146431","messageId":"201007262248.35341.jnareb@gmail.com","threadId":"24497","inReplyTo":"4C4CCE60.1080301@mit.edu","subject":"Re: [PATCH] gitweb: move highlight config out of guess_file_syntax()","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-07-26T20:48:34Z","receivedAt":"2010-07-26T20:48:34Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Mon, 26 Jul 2010, Alejandro R. Sedeño wrote:\n> On 7/25/2010 7:35 PM, Jakub Narębski wrote:\n\n> > BTW. is this something _you_ needed (and what did you need to configure\n> > / to put in $GITWEB_CONFIG file), or just a generalization?\n> \n> \n> This is something I was using in previous versions of gitweb, though\n> with the older (pre-592ea41) syntax. (I had applied the older\n> highlighting patches, and was quite happy to see them merged.)\n> \n> Before, $GITWEB_CONFIG contained lines like:\n> \n>   $highlight_type{'\\.lisp$'} = 'lisp';\n> \n> As of 1.7.2, with syntax highlighting merged and refactored (592ea41),\n> access to the hashes that define syntax highlighting mappings was lost.\n> Moving the hashes out into the config area lets $GITWEB_CONFIG contain\n> lines like:\n> \n>   $highlight_ext{'lisp'} = 'lisp';\n>   $highlight_basename{'GNUmakefile'} = 'mak';\n\nO.K., I don't think we want to put all possible languages that 'highlight'\nsupports in %highlight_ext, so you might want to add support for less\ncommon languages, or languages introduced in newer versions of tool.\n\n\nNote that you can write here\n\n    $highlight_basename{'GNUmakefile'} = 'make';\n\nwhich might be slightly more readable.\n\n-- \nJakub Narebski\nPoland\n"},{"id":"146432","messageId":"4C4DF662.5030201@mit.edu","threadId":"24497","inReplyTo":"201007262248.35341.jnareb@gmail.com","subject":"Re: [PATCH] gitweb: move highlight config out of guess_file_syntax()","fromName":"Alejandro R. Sedeño","fromEmail":"asedeno@mit.edu","sentAt":"2010-07-26T20:56:02Z","receivedAt":"2010-07-26T20:56:02Z","isPatch":true,"sender":{"key":"asedeno@mit.edu","avatar":"https://avatars.githubusercontent.com/u/28302?v=4"},"body":"On 7/26/2010 4:48 PM, Jakub Narebski wrote:\n>> As of 1.7.2, with syntax highlighting merged and refactored (592ea41),\n>> > access to the hashes that define syntax highlighting mappings was lost.\n>> > Moving the hashes out into the config area lets $GITWEB_CONFIG contain\n>> > lines like:\n>> > \n>> >   $highlight_ext{'lisp'} = 'lisp';\n>> >   $highlight_basename{'GNUmakefile'} = 'mak';\n> O.K., I don't think we want to put all possible languages that 'highlight'\n> supports in %highlight_ext, so you might want to add support for less\n> common languages, or languages introduced in newer versions of tool.\n> \n> \n> Note that you can write here\n> \n>     $highlight_basename{'GNUmakefile'} = 'make';\n> \n> which might be slightly more readable.\n\nYeah, that was a typo on my part; I was recalling samples from memory.\nThe actual entry reads 'make' not 'mak', just as you suggest. :)\n\n-Alejandro\n"},{"id":"146649","messageId":"1280342453-13938-1-git-send-email-asedeno@mit.edu","threadId":"24497","inReplyTo":"201007262245.35518.jnareb@gmail.com","subject":"[PATCH] gitweb: move highlight config out of guess_file_syntax()","fromName":"Alejandro R. Sedeño","fromEmail":"asedeno@mit.edu","sentAt":"2010-07-28T18:40:53Z","receivedAt":"2010-07-28T18:40:53Z","isPatch":true,"sender":{"key":"asedeno@mit.edu","avatar":"https://avatars.githubusercontent.com/u/28302?v=4"},"body":"Move highlight config out of guess_file_syntax() so that it can be\nextended/overridden by system/user configuration.\n\nSigned-off-by: Alejandro R. Sedeño <asedeno@mit.edu>\nAcked-by: Jakub Narebski <jnareb@gmail.com>\n---\n gitweb/gitweb.perl |   47 +++++++++++++++++++++++------------------------\n 1 files changed, 23 insertions(+), 24 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex cedc357..e0e9532 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -232,6 +232,29 @@ our %avatar_size = (\n # Leave it undefined (or set to 'undef') to turn off load checking.\n our $maxload = 300;\n \n+# configuration for 'highlight' (http://www.andre-simon.de/)\n+# match by basename\n+our %highlight_basename = (\n+\t#'Program' => 'py',\n+\t#'Library' => 'py',\n+\t'SConstruct' => 'py', # SCons equivalent of Makefile\n+\t'Makefile' => 'make',\n+);\n+# match by extension\n+our %highlight_ext = (\n+\t# main extensions, defining name of syntax;\n+\t# see files in /usr/share/highlight/langDefs/ directory\n+\tmap { $_ => $_ }\n+\t\tqw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl),\n+\t# alternate extensions, see /etc/highlight/filetypes.conf\n+\t'h' => 'c',\n+\tmap { $_ => 'cpp' } qw(cxx c++ cc),\n+\tmap { $_ => 'php' } qw(php3 php4),\n+\tmap { $_ => 'pl'  } qw(perl pm), # perhaps also 'cgi'\n+\t'mak' => 'make',\n+\tmap { $_ => 'xml' } qw(xhtml html htm),\n+);\n+\n # You define site-wide feature defaults here; override them with\n # $GITWEB_CONFIG as necessary.\n our %feature = (\n@@ -3316,30 +3339,6 @@ sub blob_contenttype {\n sub guess_file_syntax {\n \tmy ($highlight, $mimetype, $file_name) = @_;\n \treturn undef unless ($highlight && defined $file_name);\n-\n-\t# configuration for 'highlight' (http://www.andre-simon.de/)\n-\t# match by basename\n-\tmy %highlight_basename = (\n-\t\t#'Program' => 'py',\n-\t\t#'Library' => 'py',\n-\t\t'SConstruct' => 'py', # SCons equivalent of Makefile\n-\t\t'Makefile' => 'make',\n-\t);\n-\t# match by extension\n-\tmy %highlight_ext = (\n-\t\t# main extensions, defining name of syntax;\n-\t\t# see files in /usr/share/highlight/langDefs/ directory\n-\t\tmap { $_ => $_ }\n-\t\t\tqw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl),\n-\t\t# alternate extensions, see /etc/highlight/filetypes.conf\n-\t\t'h' => 'c',\n-\t\tmap { $_ => 'cpp' } qw(cxx c++ cc),\n-\t\tmap { $_ => 'php' } qw(php3 php4),\n-\t\tmap { $_ => 'pl'  } qw(perl pm), # perhaps also 'cgi'\n-\t\t'mak' => 'make',\n-\t\tmap { $_ => 'xml' } qw(xhtml html htm),\n-\t);\n-\n \tmy $basename = basename($file_name, '.in');\n \treturn $highlight_basename{$basename}\n \t\tif exists $highlight_basename{$basename};\n-- \n1.7.1\n"}]}