diff options
-rw-r--r-- | sample-frontpage.json | 5 | ||||
-rw-r--r-- | sample-question-unauthenticated.el | 65 | ||||
-rw-r--r-- | sample-question-unauthenticated.json | 1 |
3 files changed, 32 insertions, 39 deletions
diff --git a/sample-frontpage.json b/sample-frontpage.json index 8e56caf..232e02f 100644 --- a/sample-frontpage.json +++ b/sample-frontpage.json @@ -1 +1,4 @@ -{"items":[{"answers":[{"owner":{"reputation":307244,"user_id":157247,"user_type":"registered","accept_rate":90,"profile_image":"https://www.gravatar.com/avatar/ca3e484c121268e4c8302616b2395eb9?s=128&d=identicon&r=PG","display_name":"T.J. Crowder","link":"http://stackoverflow.com/users/157247/t-j-crowder"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773411,"creation_date":1414773411,"answer_id":26679414,"question_id":26679366,"body_markdown":"> Now I want to assign the color(whatever i am getting from this element) to a span element.\r\n\r\nNo you don't, you can just use `rgb(18, 115, 224)` directly for a color value in CSS.","link":"http://stackoverflow.com/questions/26679366/get-r-g-b-component-of-a-color-in-rgb-format/26679414#26679414","body":"<blockquote>\n <p>Now I want to assign the color(whatever i am getting from this element) to a span element.</p>\n</blockquote>\n\n<p>No you don't, you can just use <code>rgb(18, 115, 224)</code> directly for a color value in CSS.</p>\n"},{"owner":{"reputation":26812,"user_id":717214,"user_type":"registered","accept_rate":92,"profile_image":"https://www.gravatar.com/avatar/9075315c5f4b734a8f2567be54a4cc45?s=128&d=identicon&r=PG","display_name":"Aleks G","link":"http://stackoverflow.com/users/717214/aleks-g"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773433,"creation_date":1414773433,"answer_id":26679423,"question_id":26679366,"body_markdown":"You don't need to convert it to anything. If you want to assign this value to a span colour, then simply do:\r\n\r\n var clr = rgb(18, 115, 224);\r\n $('#myspan').css('color', clr);","link":"http://stackoverflow.com/questions/26679366/get-r-g-b-component-of-a-color-in-rgb-format/26679423#26679423","body":"<p>You don't need to convert it to anything. If you want to assign this value to a span colour, then simply do:</p>\n\n<pre><code>var clr = rgb(18, 115, 224);\n$('#myspan').css('color', clr);\n</code></pre>\n"}],"tags":["javascript","jquery","html","css","colors"],"owner":{"reputation":90,"user_id":3867678,"user_type":"registered","accept_rate":45,"profile_image":"http://graph.facebook.com/100001985977413/picture?type=large","display_name":"Rasmita Dash","link":"http://stackoverflow.com/users/3867678/rasmita-dash"},"comments":[{"owner":{"reputation":76145,"user_id":14104,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/760b4da77fd54d37c104029ff1f56749?s=128&d=identicon&r=PG","display_name":"epascarello","link":"http://stackoverflow.com/users/14104/epascarello"},"edited":false,"score":0,"creation_date":1414773413,"post_id":26679366,"comment_id":41957708}],"comment_count":1,"is_answered":false,"view_count":16,"answer_count":2,"score":0,"last_activity_date":1414773433,"creation_date":1414773223,"question_id":26679366,"body_markdown":"I am getting "rgb(18, 115, 224)" from a dom element. Now I want to assign the color(whatever i am getting from this element) to a span element. So I need hexadecimal equivalent of the color I am getting. For this I can use \r\n \r\n "#" + componentToHex(r) + componentToHex(g) + componentToHex(b)\r\nbut, My question here's how can I get the r, g,b component values from "rgb(18, 115, 224)"","link":"http://stackoverflow.com/questions/26679366/get-r-g-b-component-of-a-color-in-rgb-format","title":"get r, g, b component of a color in rgb() format","body":"<p>I am getting \"rgb(18, 115, 224)\" from a dom element. Now I want to assign the color(whatever i am getting from this element) to a span element. So I need hexadecimal equivalent of the color I am getting. For this I can use </p>\n\n<pre><code>\"#\" + componentToHex(r) + componentToHex(g) + componentToHex(b)\n</code></pre>\n\n<p>but, My question here's how can I get the r, g,b component values from \"rgb(18, 115, 224)\"</p>\n"},{"tags":["sql","sql-server","tsql"],"owner":{"reputation":1,"user_id":3406133,"user_type":"registered","profile_image":"http://graph.facebook.com/665814025/picture?type=large","display_name":"user3406133","link":"http://stackoverflow.com/users/3406133/user3406133"},"comment_count":0,"is_answered":false,"view_count":1,"answer_count":0,"score":0,"last_activity_date":1414773431,"creation_date":1414773431,"question_id":26679421,"body_markdown":"I have a table in SQL which contains the name's of certain Functions. \r\n\r\nIs it possible to select a function based on a string stored in a table? \r\n\r\nNormally I would execute the below in SSMS \r\n \r\n\r\n SELECT dbo.udfGetFileName () \r\n\r\n\r\nBut instead I want to be able to get the same result by getting the name of the function out of a Table \r\n \r\n\r\n DECLARE @GetFileName VARCHAR(30); \r\n SET @GetFileName = (SELECT FunctionName FROM Functions)\r\n SELECT @GetFileName () \r\n \r\nSomething like the above, obviosuly variables won't work but I was wondering if I could get some ideas. \r\n \r\nAny help would be apprecaited.","link":"http://stackoverflow.com/questions/26679421/sql-2005-i-would-like-to-able-to-select-a-function-which-i-declared-as-a-variabl","title":"SQL 2005 I would like to able to select a function which i declared as a variable","body":"<p>I have a table in SQL which contains the name's of certain Functions. </p>\n\n<p>Is it possible to select a function based on a string stored in a table? </p>\n\n<p>Normally I would execute the below in SSMS </p>\n\n<pre><code>SELECT dbo.udfGetFileName () \n</code></pre>\n\n<p>But instead I want to be able to get the same result by getting the name of the function out of a Table </p>\n\n<pre><code>DECLARE @GetFileName VARCHAR(30); \nSET @GetFileName = (SELECT FunctionName FROM Functions)\nSELECT @GetFileName () \n</code></pre>\n\n<p>Something like the above, obviosuly variables won't work but I was wondering if I could get some ideas. </p>\n\n<p>Any help would be apprecaited.</p>\n"},{"tags":["ruby","rvm","uninstall"],"owner":{"reputation":1,"user_id":4203256,"user_type":"registered","profile_image":"https://lh5.googleusercontent.com/-jhwW1DuKmMA/AAAAAAAAAAI/AAAAAAAAAFU/-24UhRZRMSA/photo.jpg?sz=128","display_name":"ReJam","link":"http://stackoverflow.com/users/4203256/rejam"},"comment_count":0,"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1414773430,"creation_date":1414773430,"question_id":26679422,"body_markdown":"I'm fairly new to coding and I recently came back to it after installing Homebrew and RVM months ago. Now I can't update RVM or update to the newest version of ruby through RVM so I wanted to uninstall it completely and then reinstall the newest versions from scratch. However when I run rvm implode, it doesn't seem to do anything. I can still write commands for RVM and they work. I want to completely remove all traces of RVM. What do?","link":"http://stackoverflow.com/questions/26679422/after-i-use-rvm-implode-to-uninstall-rvm-its-still-fully-functional","title":"After I use rvm implode to uninstall rvm, it's still fully functional","body":"<p>I'm fairly new to coding and I recently came back to it after installing Homebrew and RVM months ago. Now I can't update RVM or update to the newest version of ruby through RVM so I wanted to uninstall it completely and then reinstall the newest versions from scratch. However when I run rvm implode, it doesn't seem to do anything. I can still write commands for RVM and they work. I want to completely remove all traces of RVM. What do?</p>\n"},{"answers":[{"owner":{"reputation":1037,"user_id":572827,"user_type":"registered","accept_rate":62,"profile_image":"http://i.stack.imgur.com/46MgM.jpg?s=128&g=1","display_name":"LShetty","link":"http://stackoverflow.com/users/572827/lshetty"},"comment_count":0,"is_accepted":false,"score":3,"last_activity_date":1414773171,"creation_date":1414773171,"answer_id":26679350,"question_id":26679277,"body_markdown":"Use jquery filter to filter out based on your needs, like below:\r\n\r\n $('input').filter(function() {\r\n\t\treturn this.id.match(/contact_attributes_addresses_attributes_\\d+_address/i)\r\n\t}).css('prop', 'val'); // for example, set some css props for the matched elements","link":"http://stackoverflow.com/questions/26679277/jquery-find-a-selector-whose-id-contains-a-string-using-regex/26679350#26679350","body":"<p>Use jquery filter to filter out based on your needs, like below:</p>\n\n<pre><code>$('input').filter(function() {\n return this.id.match(/contact_attributes_addresses_attributes_\\d+_address/i)\n}).css('prop', 'val'); // for example, set some css props for the matched elements\n</code></pre>\n"},{"owner":{"reputation":896,"user_id":1052928,"user_type":"registered","accept_rate":71,"profile_image":"http://i.stack.imgur.com/NU1jN.jpg?s=128&g=1","display_name":"Ragnar","link":"http://stackoverflow.com/users/1052928/ragnar"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773430,"creation_date":1414773430,"answer_id":26679420,"question_id":26679277,"body_markdown":"James Padolsey created a wonderful filter that allows regex to be used for selection.\r\n\r\nTake a look at this question:\r\n\r\nhttp://stackoverflow.com/questions/190253/jquery-selector-regular-expressions\r\n","link":"http://stackoverflow.com/questions/26679277/jquery-find-a-selector-whose-id-contains-a-string-using-regex/26679420#26679420","body":"<p>James Padolsey created a wonderful filter that allows regex to be used for selection.</p>\n\n<p>Take a look at this question:</p>\n\n<p><a href=\"http://stackoverflow.com/questions/190253/jquery-selector-regular-expressions\">jQuery selector regular expressions</a></p>\n"}],"tags":["jquery","regex"],"owner":{"reputation":100,"user_id":3957231,"user_type":"registered","accept_rate":50,"profile_image":"http://graph.facebook.com/100008180384390/picture?type=large","display_name":"Dan Stayntouch","link":"http://stackoverflow.com/users/3957231/dan-stayntouch"},"comment_count":0,"is_answered":true,"view_count":25,"answer_count":2,"score":0,"last_activity_date":1414773430,"creation_date":1414772862,"question_id":26679277,"body_markdown":"I want to match input fields that match the following pattern:\r\n\r\na_profile_contact_attributes_addresses_attributes_0_address\r\nb_store_contact_attributes_addresses_attributes_3_address\r\nsomethingelse_contact_attributes_addresses_attributes_44_address\r\n\r\nIn other words, I want to use the following regex:\r\n\r\n /contact_attributes_addresses_attributes_\\d+_address/\r\n\r\nUsing jQuery, I tried the following but it returns an empty result set:\r\n\r\n $('input[id*="contact_attributes_addresses_attributes_' + /\\d+/ + '_address"]')\r\n\r\nWhat might I be doing wrong?","link":"http://stackoverflow.com/questions/26679277/jquery-find-a-selector-whose-id-contains-a-string-using-regex","title":"jquery find a selector whose id contains a string using regex","body":"<p>I want to match input fields that match the following pattern:</p>\n\n<p>a_profile_contact_attributes_addresses_attributes_0_address\nb_store_contact_attributes_addresses_attributes_3_address\nsomethingelse_contact_attributes_addresses_attributes_44_address</p>\n\n<p>In other words, I want to use the following regex:</p>\n\n<pre><code>/contact_attributes_addresses_attributes_\\d+_address/\n</code></pre>\n\n<p>Using jQuery, I tried the following but it returns an empty result set:</p>\n\n<pre><code>$('input[id*=\"contact_attributes_addresses_attributes_' + /\\d+/ + '_address\"]')\n</code></pre>\n\n<p>What might I be doing wrong?</p>\n"},{"answers":[{"owner":{"reputation":389,"user_id":3027848,"user_type":"registered","accept_rate":100,"profile_image":"http://i.stack.imgur.com/povDg.jpg?s=128&g=1","display_name":"aledustet","link":"http://stackoverflow.com/users/3027848/aledustet"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773425,"creation_date":1414773425,"answer_id":26679419,"question_id":26678784,"body_markdown":"You need to use on your second line:\r\n\r\n\r\n<!-- language: ruby -->\r\n\r\n module Spree\r\n module BaseHelper.class_eval \r\n ...\r\n end\r\n end\r\n\r\nthis should work.\r\n\r\n","link":"http://stackoverflow.com/questions/26678784/custom-meta-description-and-keyword-tags-in-spree/26679419#26679419","body":"<p>You need to use on your second line:</p>\n\n<pre class=\"lang-rb prettyprint-override\"><code>module Spree\n module BaseHelper.class_eval \n ...\n end\nend\n</code></pre>\n\n<p>this should work.</p>\n"}],"tags":["ruby-on-rails","spree"],"owner":{"reputation":848,"user_id":2229277,"user_type":"registered","accept_rate":91,"profile_image":"http://i.stack.imgur.com/LZg07.jpg?s=128&g=1","display_name":"newUserNameHere","link":"http://stackoverflow.com/users/2229277/newusernamehere"},"comment_count":0,"is_answered":false,"view_count":8,"answer_count":1,"score":0,"last_activity_date":1414773425,"creation_date":1414771170,"last_edit_date":1414772928,"question_id":26678784,"body_markdown":"I'm trying to modify the default meta descriptions and keyword tags. I'm stuck on this issue, and I don't know spree all that well.\r\n\r\nI believe they're being set here: `spree / core / app / helpers / spree / base_helper.rb`\r\n\r\nI've tried creating a file under /app/helpers/spree/base_helper_decorator.rb and put this code into it in hope of overriding the meta_data function. \r\n\r\n\r\n\r\n\r\n module Spree\r\n module BaseHelper\r\n \r\n def meta_data\r\n meta = {}\r\n \r\n meta.reverse_merge!({\r\n keywords: "test keyword",\r\n description: "test description",\r\n })\r\n meta\r\n end\r\n \r\n end\r\n end\r\n\r\nThis is not working as all my meta tags remain the same. Any help would be greatly appreciated!\r\n","link":"http://stackoverflow.com/questions/26678784/custom-meta-description-and-keyword-tags-in-spree","title":"Custom Meta Description and Keyword tags in Spree","body":"<p>I'm trying to modify the default meta descriptions and keyword tags. I'm stuck on this issue, and I don't know spree all that well.</p>\n\n<p>I believe they're being set here: <code>spree / core / app / helpers / spree / base_helper.rb</code></p>\n\n<p>I've tried creating a file under /app/helpers/spree/base_helper_decorator.rb and put this code into it in hope of overriding the meta_data function. </p>\n\n<pre><code>module Spree\n module BaseHelper\n\n def meta_data\n meta = {}\n\n meta.reverse_merge!({\n keywords: \"test keyword\",\n description: \"test description\",\n })\n meta\n end\n\n end\nend\n</code></pre>\n\n<p>This is not working as all my meta tags remain the same. Any help would be greatly appreciated!</p>\n"},{"answers":[{"owner":{"reputation":17726,"user_id":3732271,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ee6e12042dc31b1ef27471482f9ff91f?s=128&d=identicon&r=PG&f=1","display_name":"akrun","link":"http://stackoverflow.com/users/3732271/akrun"},"comments":[{"owner":{"reputation":71271,"user_id":1270695,"user_type":"registered","accept_rate":88,"profile_image":"http://i.stack.imgur.com/Fl3Sn.png?s=128&g=1","display_name":"Ananda Mahto","link":"http://stackoverflow.com/users/1270695/ananda-mahto"},"edited":false,"score":1,"creation_date":1414772001,"post_id":26678852,"comment_id":41956999},{"owner":{"reputation":17726,"user_id":3732271,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ee6e12042dc31b1ef27471482f9ff91f?s=128&d=identicon&r=PG&f=1","display_name":"akrun","link":"http://stackoverflow.com/users/3732271/akrun"},"reply_to_user":{"reputation":71271,"user_id":1270695,"user_type":"registered","accept_rate":88,"profile_image":"http://i.stack.imgur.com/Fl3Sn.png?s=128&g=1","display_name":"Ananda Mahto","link":"http://stackoverflow.com/users/1270695/ananda-mahto"},"edited":false,"score":0,"creation_date":1414772052,"post_id":26678852,"comment_id":41957030}],"last_editor":{"reputation":17726,"user_id":3732271,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ee6e12042dc31b1ef27471482f9ff91f?s=128&d=identicon&r=PG&f=1","display_name":"akrun","link":"http://stackoverflow.com/users/3732271/akrun"},"comment_count":2,"is_accepted":false,"score":1,"last_activity_date":1414772503,"last_edit_date":1414772503,"creation_date":1414771370,"answer_id":26678852,"question_id":26678722,"body_markdown":"You could also use\r\n\r\n sum(!rowSums(is.na(df[,-1])))\r\n #[1] 5\r\n\r\n###Update\r\n\r\nBased on the new dataset\r\n\r\n indx <- combn(colnames(df)[-1],2)\r\n res <- sapply(split(indx, col(indx)), function(x) \r\n sum(!rowSums(is.na(df[,x]))))\r\n\r\n names(res) <- apply(indx,2, paste, collapse="_")\r\n res\r\n # England_USA England_Brazil USA_Brazil \r\n # 5 4 3 \r\n\r\nA shorter code (as suggested by @Ananda Mahto) would be:\r\n\r\n\r\n unlist(combn(df[-1], 2, function(x) \r\n setNames(sum(complete.cases(x)), \r\n paste(names(x), collapse = "-")), simplify = FALSE))\r\n \r\n # England-USA England-Brazil USA-Brazil \r\n # 5 4 3 \r\n\r\n","link":"http://stackoverflow.com/questions/26678722/how-to-count-every-time-values-in-two-columns-are-both-not-na/26678852#26678852","body":"<p>You could also use</p>\n\n<pre><code>sum(!rowSums(is.na(df[,-1])))\n#[1] 5\n</code></pre>\n\n<h3>Update</h3>\n\n<p>Based on the new dataset</p>\n\n<pre><code> indx <- combn(colnames(df)[-1],2)\n res <- sapply(split(indx, col(indx)), function(x) \n sum(!rowSums(is.na(df[,x]))))\n\n names(res) <- apply(indx,2, paste, collapse=\"_\")\n res\n # England_USA England_Brazil USA_Brazil \n # 5 4 3 \n</code></pre>\n\n<p>A shorter code (as suggested by @Ananda Mahto) would be:</p>\n\n<pre><code> unlist(combn(df[-1], 2, function(x) \n setNames(sum(complete.cases(x)), \n paste(names(x), collapse = \"-\")), simplify = FALSE))\n\n# England-USA England-Brazil USA-Brazil \n# 5 4 3 \n</code></pre>\n"},{"owner":{"reputation":17073,"user_id":3063910,"user_type":"registered","accept_rate":94,"profile_image":"http://graph.facebook.com/1267583007/picture?type=large","display_name":"Richard Scriven","link":"http://stackoverflow.com/users/3063910/richard-scriven"},"last_editor":{"reputation":17073,"user_id":3063910,"user_type":"registered","accept_rate":94,"profile_image":"http://graph.facebook.com/1267583007/picture?type=large","display_name":"Richard Scriven","link":"http://stackoverflow.com/users/3063910/richard-scriven"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773424,"last_edit_date":1414773424,"creation_date":1414771533,"answer_id":26678897,"question_id":26678722,"body_markdown":"Here's another posibility\r\n\r\n rowSums(apply(!is.na(df[-1]), 1, function(x) {\r\n c(EU = all(x[-3]), UB = all(x[-1]), EB = all(x[-2]))\r\n }))\r\n # EU UB EB \r\n # 5 3 4 ","link":"http://stackoverflow.com/questions/26678722/how-to-count-every-time-values-in-two-columns-are-both-not-na/26678897#26678897","body":"<p>Here's another posibility</p>\n\n<pre><code>rowSums(apply(!is.na(df[-1]), 1, function(x) {\n c(EU = all(x[-3]), UB = all(x[-1]), EB = all(x[-2]))\n}))\n# EU UB EB \n# 5 3 4 \n</code></pre>\n"},{"owner":{"reputation":529,"user_id":3969377,"user_type":"registered","accept_rate":88,"profile_image":"https://www.gravatar.com/avatar/3f8dfdb77167183582d1d62390e0838b?s=128&d=identicon&r=PG&f=1","display_name":"user3969377","link":"http://stackoverflow.com/users/3969377/user3969377"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414771580,"creation_date":1414771580,"answer_id":26678909,"question_id":26678722,"body_markdown":"Use is.na with and...\r\n\r\n txt<-'players England USA\r\n 1 ben 0 3\r\n 2 josh 3 0\r\n 3 mike 3 0\r\n 4 sam 0 3\r\n 5 luis NA 1\r\n 6 john 1 NA\r\n 7 javi NA NA\r\n 8 terry 1 1 '\r\n \r\n df<-read.table(text=txt)\r\n \r\n bothNArows <- which(is.na(df$England) & is.na(df$USA))\r\n (nbad<-length(bothNArows))","link":"http://stackoverflow.com/questions/26678722/how-to-count-every-time-values-in-two-columns-are-both-not-na/26678909#26678909","body":"<p>Use is.na with and...</p>\n\n<pre><code>txt<-'players England USA\n1 ben 0 3\n2 josh 3 0\n3 mike 3 0\n4 sam 0 3\n5 luis NA 1\n6 john 1 NA\n7 javi NA NA\n8 terry 1 1 '\n\ndf<-read.table(text=txt)\n\nbothNArows <- which(is.na(df$England) & is.na(df$USA))\n(nbad<-length(bothNArows))\n</code></pre>\n"}],"tags":["r"],"owner":{"reputation":768,"user_id":1849997,"user_type":"registered","accept_rate":70,"profile_image":"http://i.stack.imgur.com/coeIX.jpg?s=128&g=1","display_name":"goldisfine","link":"http://stackoverflow.com/users/1849997/goldisfine"},"comments":[{"owner":{"reputation":17726,"user_id":3732271,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ee6e12042dc31b1ef27471482f9ff91f?s=128&d=identicon&r=PG&f=1","display_name":"akrun","link":"http://stackoverflow.com/users/3732271/akrun"},"edited":false,"score":0,"creation_date":1414771581,"post_id":26678722,"comment_id":41956755},{"owner":{"reputation":768,"user_id":1849997,"user_type":"registered","accept_rate":70,"profile_image":"http://i.stack.imgur.com/coeIX.jpg?s=128&g=1","display_name":"goldisfine","link":"http://stackoverflow.com/users/1849997/goldisfine"},"reply_to_user":{"reputation":17726,"user_id":3732271,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ee6e12042dc31b1ef27471482f9ff91f?s=128&d=identicon&r=PG&f=1","display_name":"akrun","link":"http://stackoverflow.com/users/3732271/akrun"},"edited":false,"score":0,"creation_date":1414771620,"post_id":26678722,"comment_id":41956783},{"owner":{"reputation":17073,"user_id":3063910,"user_type":"registered","accept_rate":94,"profile_image":"http://graph.facebook.com/1267583007/picture?type=large","display_name":"Richard Scriven","link":"http://stackoverflow.com/users/3063910/richard-scriven"},"edited":false,"score":1,"creation_date":1414772034,"post_id":26678722,"comment_id":41957014}],"comment_count":3,"is_answered":true,"view_count":23,"answer_count":3,"score":0,"last_activity_date":1414773424,"creation_date":1414771010,"last_edit_date":1414771456,"question_id":26678722,"body_markdown":"Let's say that I am working with data from soccer players. I have players' names, and countries that they have played in, and how many goals they've scored in these respective countries. \r\n\r\n players England USA Brazil\r\n 1 ben 0 3 NA\r\n 2 josh 3 0 2\r\n 3 mike 3 0 4\r\n 4 sam 0 3 3\r\n 5 luis NA 1 NA\r\n 6 john 1 NA 1\r\n 7 javi NA NA 3\r\n 8 terry 1 1 NA\r\n\r\nI would like to compare every pair of columns. So what I would like here is three numbers: the number of times there are two numbers in a row for the England, USA columns (5 here), the number of times there are two numbers in a row for USA, Brazil (3 here), and the number of times there are two numbers in the England, Brazil Columns (4 here).\r\n\r\n* I edited the question after a comment made me realize that posting the question with only two columns reduced the problem too much.\r\n","link":"http://stackoverflow.com/questions/26678722/how-to-count-every-time-values-in-two-columns-are-both-not-na","title":"How to count every time values in two columns are both NOT NA?","body":"<p>Let's say that I am working with data from soccer players. I have players' names, and countries that they have played in, and how many goals they've scored in these respective countries. </p>\n\n<pre><code> players England USA Brazil\n1 ben 0 3 NA\n2 josh 3 0 2\n3 mike 3 0 4\n4 sam 0 3 3\n5 luis NA 1 NA\n6 john 1 NA 1\n7 javi NA NA 3\n8 terry 1 1 NA\n</code></pre>\n\n<p>I would like to compare every pair of columns. So what I would like here is three numbers: the number of times there are two numbers in a row for the England, USA columns (5 here), the number of times there are two numbers in a row for USA, Brazil (3 here), and the number of times there are two numbers in the England, Brazil Columns (4 here).</p>\n\n<ul>\n<li>I edited the question after a comment made me realize that posting the question with only two columns reduced the problem too much.</li>\n</ul>\n"},{"answers":[{"owner":{"reputation":7472,"user_id":820127,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/81f8fffeec4f2ba3e75aebe941e4e5dd?s=128&d=identicon&r=PG","display_name":"rossum","link":"http://stackoverflow.com/users/820127/rossum"},"comments":[{"owner":{"reputation":1342,"user_id":2336725,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/20a0b96a26cf233d752469445595f872?s=128&d=identicon&r=PG","display_name":"Teepeemm","link":"http://stackoverflow.com/users/2336725/teepeemm"},"edited":false,"score":0,"creation_date":1413987871,"post_id":26497045,"comment_id":41649744},{"owner":{"reputation":7472,"user_id":820127,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/81f8fffeec4f2ba3e75aebe941e4e5dd?s=128&d=identicon&r=PG","display_name":"rossum","link":"http://stackoverflow.com/users/820127/rossum"},"reply_to_user":{"reputation":1342,"user_id":2336725,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/20a0b96a26cf233d752469445595f872?s=128&d=identicon&r=PG","display_name":"Teepeemm","link":"http://stackoverflow.com/users/2336725/teepeemm"},"edited":false,"score":0,"creation_date":1413989955,"post_id":26497045,"comment_id":41651195},{"owner":{"reputation":1342,"user_id":2336725,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/20a0b96a26cf233d752469445595f872?s=128&d=identicon&r=PG","display_name":"Teepeemm","link":"http://stackoverflow.com/users/2336725/teepeemm"},"edited":false,"score":1,"creation_date":1413996711,"post_id":26497045,"comment_id":41655596},{"owner":{"reputation":7472,"user_id":820127,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/81f8fffeec4f2ba3e75aebe941e4e5dd?s=128&d=identicon&r=PG","display_name":"rossum","link":"http://stackoverflow.com/users/820127/rossum"},"reply_to_user":{"reputation":1342,"user_id":2336725,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/20a0b96a26cf233d752469445595f872?s=128&d=identicon&r=PG","display_name":"Teepeemm","link":"http://stackoverflow.com/users/2336725/teepeemm"},"edited":false,"score":0,"creation_date":1414000356,"post_id":26497045,"comment_id":41657579},{"owner":{"reputation":7580,"user_id":2095090,"user_type":"registered","accept_rate":100,"profile_image":"http://i.stack.imgur.com/4s3og.jpg?s=128&g=1","display_name":"Vincent van der Weele","link":"http://stackoverflow.com/users/2095090/vincent-van-der-weele"},"edited":false,"score":1,"creation_date":1414259055,"post_id":26497045,"comment_id":41749889}],"comment_count":5,"is_accepted":false,"score":-1,"last_activity_date":1413928505,"creation_date":1413928505,"answer_id":26497045,"question_id":26463250,"body_markdown":"The states are one more than the powers of primes. You have numbers up to 2^8, so the power of 2 is in [0..8], which is 9 states. Similarly for the other states.\r\n\r\n"dp" could well stand for dynamic programming, I'm not sure.\r\n\r\nThe recurrence relation is the heart of the problem, so you will learn more by solving it yourself. Start with some small, simple examples.\r\n\r\nFor the large primes, try solving a reduced problem without using them (or their equivalents) and then add them back in to see their effect on the final result.","link":"http://stackoverflow.com/questions/26463250/find-the-sum-of-least-common-multiples-of-all-subsets-of-a-given-set/26497045#26497045","body":"<p>The states are one more than the powers of primes. You have numbers up to 2^8, so the power of 2 is in [0..8], which is 9 states. Similarly for the other states.</p>\n\n<p>\"dp\" could well stand for dynamic programming, I'm not sure.</p>\n\n<p>The recurrence relation is the heart of the problem, so you will learn more by solving it yourself. Start with some small, simple examples.</p>\n\n<p>For the large primes, try solving a reduced problem without using them (or their equivalents) and then add them back in to see their effect on the final result.</p>\n"},{"owner":{"reputation":15647,"user_id":2144669,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5e7393f439028063515255b63ed94cfd?s=128&d=identicon&r=PG","display_name":"David Eisenstat","link":"http://stackoverflow.com/users/2144669/david-eisenstat"},"comments":[{"owner":{"reputation":4166,"user_id":2956115,"user_type":"registered","profile_image":"http://i.stack.imgur.com/zVi0W.jpg?s=128&g=1","display_name":"artur grzesiak","link":"http://stackoverflow.com/users/2956115/artur-grzesiak"},"edited":false,"score":0,"creation_date":1414707179,"post_id":26663246,"comment_id":41930248},{"owner":{"reputation":15647,"user_id":2144669,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5e7393f439028063515255b63ed94cfd?s=128&d=identicon&r=PG","display_name":"David Eisenstat","link":"http://stackoverflow.com/users/2144669/david-eisenstat"},"reply_to_user":{"reputation":4166,"user_id":2956115,"user_type":"registered","profile_image":"http://i.stack.imgur.com/zVi0W.jpg?s=128&g=1","display_name":"artur grzesiak","link":"http://stackoverflow.com/users/2956115/artur-grzesiak"},"edited":false,"score":0,"creation_date":1414726462,"post_id":26663246,"comment_id":41935689}],"comment_count":2,"is_accepted":false,"score":2,"last_activity_date":1414703009,"creation_date":1414703009,"answer_id":26663246,"question_id":26463250,"body_markdown":"The first part of the editorial seems useful, but the second part is rather vague (and perhaps unhelpful; I'd rather finish this answer than figure it out).\r\n\r\nLet's suppose for the moment that the input consists of pairwise distinct primes, e.g., 2, 3, 5, and 7. Then the answer (for summing all sets, where the LCM of 0 integers is 1) is\r\n\r\n (1 + 2) (1 + 3) (1 + 5) (1 + 7),\r\n\r\nbecause the LCM of a subset is exactly equal to the product here, so just multiply it out.\r\n\r\nLet's relax the restriction that the primes be pairwise distinct. If we have an input like 2, 2, 3, 3, 3, and 5, then the multiplication looks like\r\n\r\n (1 + (2^2 - 1) 2) (1 + (2^3 - 1) 3) (1 + (2^1 - 1) 5),\r\n\r\nbecause 2 appears with multiplicity 2, and 3 appears with multiplicity 3, and 5 appears with multiplicity 1. With respect to, e.g., just the set of 3s, there are `2^3 - 1` ways to choose a subset that includes a 3, and `1` way to choose the empty set.\r\n\r\nCall a prime *small* if it's 19 or less and *large* otherwise. Note that integers 500 or less are divisible by at most one large prime (with multiplicity). The small primes are more problematic. What we're going to do is to compute, for each possible small portion of the prime factorization of the LCM (i.e., one of the ~70,000 states), the sum of LCMs for the problem derived by discarding the integers that could not divide such an LCM and leaving only the large prime factor (or 1) for the other integers.\r\n\r\nFor example, if the input is 2, 30, 41, 46, and 51, and the state is 2, then we retain 2 as 1, discard 30 (= 2 * 3 * 5; 3 and 5 are small), retain 41 as 41 (41 is large), retain 46 as 23 (= 2 * 23; 23 is large), and discard 51 (= 3 * 17; 3 and 17 are small). Now, we compute the sum of LCMs using the previously described technique. Use [inclusion-exclusion](https://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_principle) to get rid of the subsets whose LCM whose small portion properly divides the state instead of being exactly equal. Maybe I'll work a complete example later.","link":"http://stackoverflow.com/questions/26463250/find-the-sum-of-least-common-multiples-of-all-subsets-of-a-given-set/26663246#26663246","body":"<p>The first part of the editorial seems useful, but the second part is rather vague (and perhaps unhelpful; I'd rather finish this answer than figure it out).</p>\n\n<p>Let's suppose for the moment that the input consists of pairwise distinct primes, e.g., 2, 3, 5, and 7. Then the answer (for summing all sets, where the LCM of 0 integers is 1) is</p>\n\n<pre><code>(1 + 2) (1 + 3) (1 + 5) (1 + 7),\n</code></pre>\n\n<p>because the LCM of a subset is exactly equal to the product here, so just multiply it out.</p>\n\n<p>Let's relax the restriction that the primes be pairwise distinct. If we have an input like 2, 2, 3, 3, 3, and 5, then the multiplication looks like</p>\n\n<pre><code>(1 + (2^2 - 1) 2) (1 + (2^3 - 1) 3) (1 + (2^1 - 1) 5),\n</code></pre>\n\n<p>because 2 appears with multiplicity 2, and 3 appears with multiplicity 3, and 5 appears with multiplicity 1. With respect to, e.g., just the set of 3s, there are <code>2^3 - 1</code> ways to choose a subset that includes a 3, and <code>1</code> way to choose the empty set.</p>\n\n<p>Call a prime <em>small</em> if it's 19 or less and <em>large</em> otherwise. Note that integers 500 or less are divisible by at most one large prime (with multiplicity). The small primes are more problematic. What we're going to do is to compute, for each possible small portion of the prime factorization of the LCM (i.e., one of the ~70,000 states), the sum of LCMs for the problem derived by discarding the integers that could not divide such an LCM and leaving only the large prime factor (or 1) for the other integers.</p>\n\n<p>For example, if the input is 2, 30, 41, 46, and 51, and the state is 2, then we retain 2 as 1, discard 30 (= 2 * 3 * 5; 3 and 5 are small), retain 41 as 41 (41 is large), retain 46 as 23 (= 2 * 23; 23 is large), and discard 51 (= 3 * 17; 3 and 17 are small). Now, we compute the sum of LCMs using the previously described technique. Use <a href=\"https://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_principle\" rel=\"nofollow\">inclusion-exclusion</a> to get rid of the subsets whose LCM whose small portion properly divides the state instead of being exactly equal. Maybe I'll work a complete example later.</p>\n"},{"owner":{"reputation":4216,"user_id":873886,"user_type":"registered","accept_rate":56,"profile_image":"https://www.gravatar.com/avatar/344697d54c0db06b0a9a426f6e319374?s=128&d=identicon&r=PG","display_name":"Kaganar","link":"http://stackoverflow.com/users/873886/kaganar"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773420,"creation_date":1414773420,"answer_id":26679418,"question_id":26463250,"body_markdown":"Discussion\r\n-\r\nAfter reading the actual contest description ([page 10 or 11][1]) and the solution sketch, I have to conclude the author of the solution sketch is quite imprecise in their writing.\r\n\r\nThe high level problem is to calculate an expected lifetime if components are chosen randomly by fair coin toss. This is what's leading to computing the LCM of all subsets -- all subsets effectively represent the sample space. You could end up with any possible set of components. The failure time for the device is based on the LCM of the set. The expected lifetime is therefore the average of the LCM of all sets.\r\n\r\nNote that this ought to include the LCM of sets with only one item (in which case we'd assume the LCM to be the element itself). The solution sketch seems to sabotage, perhaps because they handled it in a less elegant manner.\r\n\r\nWhat is meant by these states?\r\n-\r\nThe sketch author only uses the word *state* twice, but apparently manages to switch meanings. In the first use of the word *state* it appears they're talking about a possible selection of components. In the second use they're likely talking about possible failure times. They're could be muddling this terminology because their dynamic programming solution initializes values from one use of the word and the recurrence relation stems from the other.\r\n\r\n\r\nDoes dp stand for dynamic programming?\r\n-\r\nI would say either it does or it's a coincidence as the solution sketch seems to heavily imply dynamic programming.\r\n\r\nIf so, what recurrence relation is being solved? How is dp[i] computed from dp[i-1]?\r\n-\r\n\r\nAll I can think is that in their solution, *state* `i` represents a time to failure , `T(i)`, with the number of times this time to failure has been counted, `dp[i]`. The resulting sum would be to sum all `dp[i] * T(i)`.\r\n\r\n`dp[i][0]` would then be the failure times counted for only the first component. `dp[i][1]` would then be the failure times counted for the first and second component. `dp[i][2]` would be for the first, second, and third. Etc..\r\n\r\nInitialize `dp[i][0]` with zeroes except for `dp[T(c)][0]` (where `c` is the first component considered) which should be 1 (since this component's failure time has been counted once so far).\r\n\r\nTo populate `dp[i][n]` from `dp[i][n-1]` for each component `c`:\r\n\r\n- For each `i`, copy `dp[i][n-1]` into `dp[i][n]`.\r\n- Add 1 to `dp[T(c)][n]`.\r\n- For each `i`, add `dp[i][n-1]` to `dp[LCM(T(i), T(c))][n]`.\r\n\r\nWhat is this doing? Suppose you knew that you had a time to failure of `j`, but you added a component with a time to failure of `k`. Regardless of what components you had before, your new time to fail is `LCM(j, k)`. This follows from the fact that for two sets `A` and `B`, `LCM(A union B} = LCM(LCM(A), LCM(B))`.\r\n\r\nSimilarly, if we're considering a time to failure of `T(i)` and our new component's time to failure of `T(c)`, the resultant time to failure is `LCM(T(i), T(c))`. Note that we recorded this time to failure for `dp[i][n-1]` configurations, so we should record that many new times to failure once the new component is introduced.\r\n\r\nWhy do the big primes not contribute to the number of states?\r\n-\r\n> Each of them occurs either 0 or 1 times. Should the number of states not be multiplied by 2 for each of these primes (leading to a non-feasible state space again)?\r\n\r\nYou're right, of course. However, the solution sketch states that numbers with large primes are handled in another (unspecified) fashion.\r\n\r\nWhat would happen if we did include them? The number of *states* we would need to represent would explode into an impractical number. Hence the author accounts for such numbers differently. Note that if a number less than or equal to 500 includes a prime larger than 19 the other factors multiply to 21 or less. This makes such numbers amenable for brute forcing, no tables necessary.\r\n\r\n\r\n [1]: http://acm-icpc.coe.psu.ac.th/contest-problem/contest-acm-asia-hy-2012-final.pdf","link":"http://stackoverflow.com/questions/26463250/find-the-sum-of-least-common-multiples-of-all-subsets-of-a-given-set/26679418#26679418","body":"<h2>Discussion</h2>\n\n<p>After reading the actual contest description (<a href=\"http://acm-icpc.coe.psu.ac.th/contest-problem/contest-acm-asia-hy-2012-final.pdf\" rel=\"nofollow\">page 10 or 11</a>) and the solution sketch, I have to conclude the author of the solution sketch is quite imprecise in their writing.</p>\n\n<p>The high level problem is to calculate an expected lifetime if components are chosen randomly by fair coin toss. This is what's leading to computing the LCM of all subsets -- all subsets effectively represent the sample space. You could end up with any possible set of components. The failure time for the device is based on the LCM of the set. The expected lifetime is therefore the average of the LCM of all sets.</p>\n\n<p>Note that this ought to include the LCM of sets with only one item (in which case we'd assume the LCM to be the element itself). The solution sketch seems to sabotage, perhaps because they handled it in a less elegant manner.</p>\n\n<h2>What is meant by these states?</h2>\n\n<p>The sketch author only uses the word <em>state</em> twice, but apparently manages to switch meanings. In the first use of the word <em>state</em> it appears they're talking about a possible selection of components. In the second use they're likely talking about possible failure times. They're could be muddling this terminology because their dynamic programming solution initializes values from one use of the word and the recurrence relation stems from the other.</p>\n\n<h2>Does dp stand for dynamic programming?</h2>\n\n<p>I would say either it does or it's a coincidence as the solution sketch seems to heavily imply dynamic programming.</p>\n\n<h2>If so, what recurrence relation is being solved? How is dp[i] computed from dp[i-1]?</h2>\n\n<p>All I can think is that in their solution, <em>state</em> <code>i</code> represents a time to failure , <code>T(i)</code>, with the number of times this time to failure has been counted, <code>dp[i]</code>. The resulting sum would be to sum all <code>dp[i] * T(i)</code>.</p>\n\n<p><code>dp[i][0]</code> would then be the failure times counted for only the first component. <code>dp[i][1]</code> would then be the failure times counted for the first and second component. <code>dp[i][2]</code> would be for the first, second, and third. Etc..</p>\n\n<p>Initialize <code>dp[i][0]</code> with zeroes except for <code>dp[T(c)][0]</code> (where <code>c</code> is the first component considered) which should be 1 (since this component's failure time has been counted once so far).</p>\n\n<p>To populate <code>dp[i][n]</code> from <code>dp[i][n-1]</code> for each component <code>c</code>:</p>\n\n<ul>\n<li>For each <code>i</code>, copy <code>dp[i][n-1]</code> into <code>dp[i][n]</code>.</li>\n<li>Add 1 to <code>dp[T(c)][n]</code>.</li>\n<li>For each <code>i</code>, add <code>dp[i][n-1]</code> to <code>dp[LCM(T(i), T(c))][n]</code>.</li>\n</ul>\n\n<p>What is this doing? Suppose you knew that you had a time to failure of <code>j</code>, but you added a component with a time to failure of <code>k</code>. Regardless of what components you had before, your new time to fail is <code>LCM(j, k)</code>. This follows from the fact that for two sets <code>A</code> and <code>B</code>, <code>LCM(A union B} = LCM(LCM(A), LCM(B))</code>.</p>\n\n<p>Similarly, if we're considering a time to failure of <code>T(i)</code> and our new component's time to failure of <code>T(c)</code>, the resultant time to failure is <code>LCM(T(i), T(c))</code>. Note that we recorded this time to failure for <code>dp[i][n-1]</code> configurations, so we should record that many new times to failure once the new component is introduced.</p>\n\n<h2>Why do the big primes not contribute to the number of states?</h2>\n\n<blockquote>\n <p>Each of them occurs either 0 or 1 times. Should the number of states not be multiplied by 2 for each of these primes (leading to a non-feasible state space again)?</p>\n</blockquote>\n\n<p>You're right, of course. However, the solution sketch states that numbers with large primes are handled in another (unspecified) fashion.</p>\n\n<p>What would happen if we did include them? The number of <em>states</em> we would need to represent would explode into an impractical number. Hence the author accounts for such numbers differently. Note that if a number less than or equal to 500 includes a prime larger than 19 the other factors multiply to 21 or less. This makes such numbers amenable for brute forcing, no tables necessary.</p>\n"}],"tags":["algorithm","computer-science","dynamic-programming","primes","prime-factoring"],"owner":{"reputation":146,"user_id":2472641,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/d734b762d636b11eca7cf2303325c2c0?s=128&d=identicon&r=PG","display_name":"MasterMind","link":"http://stackoverflow.com/users/2472641/mastermind"},"comments":[{"owner":{"reputation":313,"user_id":3455829,"user_type":"registered","profile_image":"http://i.stack.imgur.com/DxqTQ.gif?s=128&g=1","display_name":"Ralor","link":"http://stackoverflow.com/users/3455829/ralor"},"reply_to_user":{"reputation":2440,"user_id":2741705,"user_type":"registered","profile_image":"http://graph.facebook.com/1478197909/picture?type=large","display_name":"Pham Trung","link":"http://stackoverflow.com/users/2741705/pham-trung"},"edited":false,"score":1,"creation_date":1413904304,"post_id":26463250,"comment_id":41614065},{"owner":{"reputation":7580,"user_id":2095090,"user_type":"registered","accept_rate":100,"profile_image":"http://i.stack.imgur.com/4s3og.jpg?s=128&g=1","display_name":"Vincent van der Weele","link":"http://stackoverflow.com/users/2095090/vincent-van-der-weele"},"edited":false,"score":1,"creation_date":1413922983,"post_id":26463250,"comment_id":41624393},{"owner":{"reputation":146,"user_id":2472641,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/d734b762d636b11eca7cf2303325c2c0?s=128&d=identicon&r=PG","display_name":"MasterMind","link":"http://stackoverflow.com/users/2472641/mastermind"},"reply_to_user":{"reputation":7580,"user_id":2095090,"user_type":"registered","accept_rate":100,"profile_image":"http://i.stack.imgur.com/4s3og.jpg?s=128&g=1","display_name":"Vincent van der Weele","link":"http://stackoverflow.com/users/2095090/vincent-van-der-weele"},"edited":false,"score":0,"creation_date":1414017796,"post_id":26463250,"comment_id":41666332}],"comment_count":3,"is_answered":true,"view_count":186,"bounty_amount":100,"bounty_closes_date":1415297825,"answer_count":3,"score":9,"last_activity_date":1414773420,"creation_date":1413800137,"last_edit_date":1413922680,"question_id":26463250,"body_markdown":"**Given:** set <code>A = {a<sub>0</sub>, a<sub>1</sub>, ..., a<sub>N-1</sub>}</code> (<code>1 &leq; N &leq; 100</code>), with <code>2 &leq; a<sub>i</sub> &leq; 500</code>.\r\n\r\n**Asked:** Find the sum of all least common multiples (LCM) of all subsets of `A` of size at least 2.\r\n\r\nThe LCM of a set<code>B = {b<sub>0</sub>, b<sub>1</sub>, ..., b<sub>k-1</sub>}</code> is defined as the minimum integer <code>B<sub>min</sub></code> such that <code>b<sub>i</sub> | B<sub>min</sub></code>, for all <code>0 &leq; i < k</code>.\r\n\r\n**Example:**\r\n\r\nLet `N = 3` and `A = {2, 6, 7}`, then:\r\n\r\n LCM({2, 6}) = 6\r\n LCM({2, 7}) = 14\r\n LCM({6, 7}) = 42\r\n LCM({2, 6, 7}) = 42\r\n ----------------------- +\r\n answer 104\r\n\r\nThe naive approach would be to simply calculate the LCM for all <code>O(2<sup>N</sup>)</code> subsets, which is not feasible for reasonably large `N`.\r\n\r\n---\r\n\r\n**Solution sketch:**\r\n\r\nThe problem is obtained from a competition<sup>*</sup>, which also provided a [solution sketch][1]. This is where my problem comes in: I do not understand the hinted approach.\r\n\r\nThe solution reads (modulo some small fixed grammar issues):\r\n\r\n> The solution is a bit tricky. If we observe carefully we see that the integers are between `2` and `500`. So, if we prime factorize the numbers, we get the following maximum powers:\r\n\r\n 2 8 \r\n 3 5\r\n 5 3\r\n 7 3\r\n 11 2\r\n 13 2\r\n 17 2\r\n 19 2\r\n\r\n> Other than this, all primes have power 1. So, we can easily calculate all possible states, using these integers, leaving `9 * 6 * 4 * 4 * 3 * 3 * 3 * 3` states, which is nearly `70000`. For other integers we can make a dp like the following: `dp[70000][i]`, where `i` can be `0` to `100`. However, as `dp[i]` is dependent on `dp[i-1]`, so `dp[70000][2]` is enough. This leaves the complexity to `n * 70000` which is feasible.\r\n\r\nI have the following concrete questions:\r\n\r\n - What is meant by these states?\r\n - Does `dp` stand for dynamic programming and if so, what recurrence relation is being solved?\r\n - How is `dp[i]` computed from `dp[i-1]`?\r\n - Why do the big primes not contribute to the number of states? Each of them occurs either `0` or `1` times. Should the number of states not be multiplied by `2` for each of these primes (leading to a non-feasible state space again)?\r\n\r\n<sub><sup>*</sup>The original problem description can be found from [this source][2] (problem F). This question is a simplified version of that description.</sub>\r\n\r\n\r\n [1]: http://acm-icpc.coe.psu.ac.th/contest-problem/solution-sketch-UltimateDevice.pdf\r\n [2]: http://acm-icpc.coe.psu.ac.th/contest-problem/contest-acm-asia-hy-2012-final.pdf","link":"http://stackoverflow.com/questions/26463250/find-the-sum-of-least-common-multiples-of-all-subsets-of-a-given-set","title":"Find the sum of least common multiples of all subsets of a given set","body":"<p><strong>Given:</strong> set <code>A = {a<sub>0</sub>, a<sub>1</sub>, ..., a<sub>N-1</sub>}</code> (<code>1 ≤ N ≤ 100</code>), with <code>2 ≤ a<sub>i</sub> ≤ 500</code>.</p>\n\n<p><strong>Asked:</strong> Find the sum of all least common multiples (LCM) of all subsets of <code>A</code> of size at least 2.</p>\n\n<p>The LCM of a set<code>B = {b<sub>0</sub>, b<sub>1</sub>, ..., b<sub>k-1</sub>}</code> is defined as the minimum integer <code>B<sub>min</sub></code> such that <code>b<sub>i</sub> | B<sub>min</sub></code>, for all <code>0 ≤ i < k</code>.</p>\n\n<p><strong>Example:</strong></p>\n\n<p>Let <code>N = 3</code> and <code>A = {2, 6, 7}</code>, then:</p>\n\n<pre><code>LCM({2, 6}) = 6\nLCM({2, 7}) = 14\nLCM({6, 7}) = 42\nLCM({2, 6, 7}) = 42\n----------------------- +\nanswer 104\n</code></pre>\n\n<p>The naive approach would be to simply calculate the LCM for all <code>O(2<sup>N</sup>)</code> subsets, which is not feasible for reasonably large <code>N</code>.</p>\n\n<hr>\n\n<p><strong>Solution sketch:</strong></p>\n\n<p>The problem is obtained from a competition<sup>*</sup>, which also provided a <a href=\"http://acm-icpc.coe.psu.ac.th/contest-problem/solution-sketch-UltimateDevice.pdf\">solution sketch</a>. This is where my problem comes in: I do not understand the hinted approach.</p>\n\n<p>The solution reads (modulo some small fixed grammar issues):</p>\n\n<blockquote>\n <p>The solution is a bit tricky. If we observe carefully we see that the integers are between <code>2</code> and <code>500</code>. So, if we prime factorize the numbers, we get the following maximum powers:</p>\n</blockquote>\n\n<pre><code> 2 8 \n 3 5\n 5 3\n 7 3\n11 2\n13 2\n17 2\n19 2\n</code></pre>\n\n<blockquote>\n <p>Other than this, all primes have power 1. So, we can easily calculate all possible states, using these integers, leaving <code>9 * 6 * 4 * 4 * 3 * 3 * 3 * 3</code> states, which is nearly <code>70000</code>. For other integers we can make a dp like the following: <code>dp[70000][i]</code>, where <code>i</code> can be <code>0</code> to <code>100</code>. However, as <code>dp[i]</code> is dependent on <code>dp[i-1]</code>, so <code>dp[70000][2]</code> is enough. This leaves the complexity to <code>n * 70000</code> which is feasible.</p>\n</blockquote>\n\n<p>I have the following concrete questions:</p>\n\n<ul>\n<li>What is meant by these states?</li>\n<li>Does <code>dp</code> stand for dynamic programming and if so, what recurrence relation is being solved?</li>\n<li>How is <code>dp[i]</code> computed from <code>dp[i-1]</code>?</li>\n<li>Why do the big primes not contribute to the number of states? Each of them occurs either <code>0</code> or <code>1</code> times. Should the number of states not be multiplied by <code>2</code> for each of these primes (leading to a non-feasible state space again)?</li>\n</ul>\n\n<p><sub><sup>*</sup>The original problem description can be found from <a href=\"http://acm-icpc.coe.psu.ac.th/contest-problem/contest-acm-asia-hy-2012-final.pdf\">this source</a> (problem F). This question is a simplified version of that description.</sub></p>\n"},{"tags":["java","swing","graphics","rotation","awt"],"owner":{"reputation":1,"user_id":1485930,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2bc89b982edddfc9ef0c8aa3f7d45181?s=128&d=identicon&r=PG","display_name":"Ali Abdallah","link":"http://stackoverflow.com/users/1485930/ali-abdallah"},"comment_count":0,"is_answered":false,"view_count":1,"answer_count":0,"score":0,"last_activity_date":1414773419,"creation_date":1414773419,"question_id":26679417,"body_markdown":"i have an extended JLabel class, called OrientationLabel, holding a single character. That character is '>' and inside my extended class is a function called flip which basically changes the character from '>' to '<'. anyway what i want to do is rotate the label in order for it to align with an edge. \r\n\r\nNote: I also have an edge class which consists of two Point objects. inside that class is a function called center() which returns a computed center Point object in between the two points that form the edge. and also an angle() function that computes the angle that the edge makes.\r\n\r\ni pass the angle and center point to my constructor of my orientation label and here is my resulting paintComponent function:\r\n\r\n\r\n @Override\r\n public void paintComponent(Graphics g){\r\n \r\n Graphics2D g2 = (Graphics2D)g;\r\n \r\n this.setLocation(Math.round(center.getX() - (getWidth()/2)), Math.round(center.getY() - (getHeight()/2)));\r\n g2.rotate(-rotation, getWidth() / 2, getHeight() / 2);\r\n \r\n super.paintComponent(g);\r\n \r\n }\r\n\r\n\r\nThe problem is that as i rotate the label, sometimes it does not align exactly with the line. It points along the direction ok and the flip() function works perfectly but like i said sometimes you can tell its not perfectly aligned. Also i feel it sometimes comes out a little skewed.\r\n\r\nI'm guessing this has something to do with the rotational center. If the width of the character is an odd number then the center will be a pixel rather than half a pixel? \r\n\r\nKeep in mind i have been using java for a very long time in uni however we never really explored using the Graphics/Graphics2D classes therefore i would also appreciate some good resources where i can quickly learn these concepts/hierarchies a little better.","link":"http://stackoverflow.com/questions/26679417/java-rotation-of-a-jlabel-using-arbitrary-angles","title":"Java rotation of a JLabel using arbitrary angles","body":"<p>i have an extended JLabel class, called OrientationLabel, holding a single character. That character is '>' and inside my extended class is a function called flip which basically changes the character from '>' to '<'. anyway what i want to do is rotate the label in order for it to align with an edge. </p>\n\n<p>Note: I also have an edge class which consists of two Point objects. inside that class is a function called center() which returns a computed center Point object in between the two points that form the edge. and also an angle() function that computes the angle that the edge makes.</p>\n\n<p>i pass the angle and center point to my constructor of my orientation label and here is my resulting paintComponent function:</p>\n\n<p>@Override\n public void paintComponent(Graphics g){</p>\n\n<pre><code> Graphics2D g2 = (Graphics2D)g;\n\n this.setLocation(Math.round(center.getX() - (getWidth()/2)), Math.round(center.getY() - (getHeight()/2)));\n g2.rotate(-rotation, getWidth() / 2, getHeight() / 2);\n\n super.paintComponent(g);\n\n}\n</code></pre>\n\n<p>The problem is that as i rotate the label, sometimes it does not align exactly with the line. It points along the direction ok and the flip() function works perfectly but like i said sometimes you can tell its not perfectly aligned. Also i feel it sometimes comes out a little skewed.</p>\n\n<p>I'm guessing this has something to do with the rotational center. If the width of the character is an odd number then the center will be a pixel rather than half a pixel? </p>\n\n<p>Keep in mind i have been using java for a very long time in uni however we never really explored using the Graphics/Graphics2D classes therefore i would also appreciate some good resources where i can quickly learn these concepts/hierarchies a little better.</p>\n"},{"answers":[{"owner":{"reputation":69820,"user_id":165737,"user_type":"registered","accept_rate":97,"profile_image":"http://i.stack.imgur.com/odROI.jpg?s=128&g=1","display_name":"Anurag","link":"http://stackoverflow.com/users/165737/anurag"},"last_editor":{"reputation":69820,"user_id":165737,"user_type":"registered","accept_rate":97,"profile_image":"http://i.stack.imgur.com/odROI.jpg?s=128&g=1","display_name":"Anurag","link":"http://stackoverflow.com/users/165737/anurag"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1262921229,"last_edit_date":1262921229,"creation_date":1262915058,"answer_id":2024926,"question_id":2024691,"body_markdown":"Actually, you can resize a canvas using stylesheets. The results may vary across browsers as HTML5 is still in the process of being finalized. \r\n\r\nThere is no `width` or `height` property for a drawing context, only for canvas. A context's `scale` is used to resize the unit step size in `x` or `y` dimensions and it doesn't have to be proportional. For example,\r\n\r\n context.scale(5, 1);\r\n\r\nchanges the `x` unit size to 5, and y's to 1. If we draw a 30x30 square now, it will actually come out to be 150x30 as `x` has been scaled 5 times while `y` remains the same. If you want the logo to be larger, increase the context scale **before** drawing your logo.\r\n\r\nMozilla has a good tutorial on [scaling and transformations][1] in general.\r\n\r\n**Edit**: In response to your comment, the logo's size and canvas dimensions will determine what should be the scaling factor for enlarging the image. If the logo is 100x100 px in size and the canvas is 800x600, then you are limited by canvas height (600) as its smaller. So the maximum scaling that you can do without clipping part of the logo outside canvas will be 600/100 = 6\r\n\r\n context.scale(6, 6)\r\n\r\nThese numbers will vary and you can do your own calculations to find the optimal size.\r\n\r\n [1]: https://developer.mozilla.org/en/Canvas_tutorial/Transformations "Scaling and Transformations"","link":"http://stackoverflow.com/questions/2024691/scaling-logo-in-html5-canvas/2024926#2024926","body":"<p>Actually, you can resize a canvas using stylesheets. The results may vary across browsers as HTML5 is still in the process of being finalized. </p>\n\n<p>There is no <code>width</code> or <code>height</code> property for a drawing context, only for canvas. A context's <code>scale</code> is used to resize the unit step size in <code>x</code> or <code>y</code> dimensions and it doesn't have to be proportional. For example,</p>\n\n<pre><code>context.scale(5, 1);\n</code></pre>\n\n<p>changes the <code>x</code> unit size to 5, and y's to 1. If we draw a 30x30 square now, it will actually come out to be 150x30 as <code>x</code> has been scaled 5 times while <code>y</code> remains the same. If you want the logo to be larger, increase the context scale <strong>before</strong> drawing your logo.</p>\n\n<p>Mozilla has a good tutorial on <a href=\"https://developer.mozilla.org/en/Canvas_tutorial/Transformations\" rel=\"nofollow\" title=\"Scaling and Transformations\">scaling and transformations</a> in general.</p>\n\n<p><strong>Edit</strong>: In response to your comment, the logo's size and canvas dimensions will determine what should be the scaling factor for enlarging the image. If the logo is 100x100 px in size and the canvas is 800x600, then you are limited by canvas height (600) as its smaller. So the maximum scaling that you can do without clipping part of the logo outside canvas will be 600/100 = 6</p>\n\n<pre><code>context.scale(6, 6)\n</code></pre>\n\n<p>These numbers will vary and you can do your own calculations to find the optimal size.</p>\n"},{"owner":{"reputation":22827,"user_id":109374,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b6939793be07c69fe4f783dd442e902d?s=128&d=identicon&r=PG","display_name":"Erik Dahlström","link":"http://stackoverflow.com/users/109374/erik-dahlstr%c3%b6m"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1262942338,"creation_date":1262942338,"answer_id":2026532,"question_id":2024691,"body_markdown":"You could convert the logo to svg and let the browser do the scaling for you, with or without adding css mediaqueries.\r\n\r\nCheck out Andreas Bovens' [presentation and examples][1].\r\n\r\n\r\n [1]: http://my.opera.com/ODIN/blog/2009/10/12/how-media-queries-allow-you-to-optimize-svg-icons-for-several-sizes","link":"http://stackoverflow.com/questions/2024691/scaling-logo-in-html5-canvas/2026532#2026532","body":"<p>You could convert the logo to svg and let the browser do the scaling for you, with or without adding css mediaqueries.</p>\n\n<p>Check out Andreas Bovens' <a href=\"http://my.opera.com/ODIN/blog/2009/10/12/how-media-queries-allow-you-to-optimize-svg-icons-for-several-sizes\" rel=\"nofollow\">presentation and examples</a>.</p>\n"},{"owner":{"reputation":2549,"user_id":172378,"user_type":"registered","accept_rate":100,"profile_image":"http://i.stack.imgur.com/Ceji6.jpg?s=128&g=1","display_name":"Delta","link":"http://stackoverflow.com/users/172378/delta"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1263158749,"creation_date":1263158749,"answer_id":2038693,"question_id":2024691,"body_markdown":"You can resize the image when you draw it\r\n\r\n imageobject=new Image();\r\n imageobject.src="imagefile";\r\n imageobject.onload=function(){\r\n \tcontext.drawImage(imageobject,0,0,imageobject.width,imageobject.height,0,0,800,600);\r\n }\r\n\r\nThe last 2 arguments are the width an height to resize the image\r\n\r\nhttp://www.w3.org/TR/html5/the-canvas-element.html#dom-context-2d-drawimage\r\n","link":"http://stackoverflow.com/questions/2024691/scaling-logo-in-html5-canvas/2038693#2038693","body":"<p>You can resize the image when you draw it</p>\n\n<pre><code>imageobject=new Image();\nimageobject.src=\"imagefile\";\nimageobject.onload=function(){\n context.drawImage(imageobject,0,0,imageobject.width,imageobject.height,0,0,800,600);\n}\n</code></pre>\n\n<p>The last 2 arguments are the width an height to resize the image</p>\n\n<p><a href=\"http://www.w3.org/TR/html5/the-canvas-element.html#dom-context-2d-drawimage\" rel=\"nofollow\">http://www.w3.org/TR/html5/the-canvas-element.html#dom-context-2d-drawimage</a></p>\n"},{"owner":{"reputation":2697,"user_id":379650,"user_type":"registered","accept_rate":88,"profile_image":"https://www.gravatar.com/avatar/294c2d2b6a287b133e66c35bb3de57cd?s=128&d=identicon&r=PG","display_name":"qw3n","link":"http://stackoverflow.com/users/379650/qw3n"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1278307742,"creation_date":1278307742,"answer_id":3177368,"question_id":2024691,"body_markdown":"If you set the `element.style.width` and `element.style.height` attributes (assuming element is a canvas element) you are stretching the contents of the canvas. If you set the `element.width` and `element.height` you are resizing the canvas itself not the content. The `ctx.scale` is for dynamic resizing whenever you drawing something with javascript and gives you the same stretching effect as `element.style`.","link":"http://stackoverflow.com/questions/2024691/scaling-logo-in-html5-canvas/3177368#3177368","body":"<p>If you set the <code>element.style.width</code> and <code>element.style.height</code> attributes (assuming element is a canvas element) you are stretching the contents of the canvas. If you set the <code>element.width</code> and <code>element.height</code> you are resizing the canvas itself not the content. The <code>ctx.scale</code> is for dynamic resizing whenever you drawing something with javascript and gives you the same stretching effect as <code>element.style</code>.</p>\n"}],"tags":["html","html5","canvas"],"owner":{"reputation":1,"user_id":246039,"user_type":"unregistered","profile_image":"https://www.gravatar.com/avatar/30a83423ee0a48578a5ede86c7f77b52?s=128&d=identicon&r=PG","display_name":"miles","link":"http://stackoverflow.com/users/246039/miles"},"comment_count":0,"is_answered":false,"view_count":5423,"answer_count":4,"score":0,"last_activity_date":1414773417,"creation_date":1262910150,"last_edit_date":1317898832,"question_id":2024691,"body_markdown":"Having trouble scaling with <canvas>. It seems to make sense to code up a drawing in canvas to a fixed size (ie 800x600) then scale it for specific locations - but sizing occurs in 4 places: 1) in the context definition (ie ctx.width = 800 2) with ctx.scale; 3) in html with <canvas width=... and with css for the div - what is the best way if the drawing is done at 800 x 600 to fit it into different div sizes ie 200 x 150 ? \r\n\r\nI can scale it with ctx.scale(0.25,0.25) and use <canvas width="200" height="150"> but this doesn't appear right - it seems to want the scale to be proportional. \r\n\r\ncss sizing simply makes it fuzzy so not a good way to go. Any ideas? ","link":"http://stackoverflow.com/questions/2024691/scaling-logo-in-html5-canvas","title":"scaling logo in html5 <canvas>?","body":"<p>Having trouble scaling with . It seems to make sense to code up a drawing in canvas to a fixed size (ie 800x600) then scale it for specific locations - but sizing occurs in 4 places: 1) in the context definition (ie ctx.width = 800 2) with ctx.scale; 3) in html with \n\n<p>I can scale it with ctx.scale(0.25,0.25) and use but this doesn't appear right - it seems to want the scale to be proportional. </p>\n\n<p>css sizing simply makes it fuzzy so not a good way to go. Any ideas? </p>\n"},{"answers":[{"owner":{"reputation":4993,"user_id":1185262,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5a3d9f0dcb7b133e92d2cd76e748702d?s=128&d=identicon&r=PG","display_name":"jesse mcconnell","link":"http://stackoverflow.com/users/1185262/jesse-mcconnell"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1342216018,"creation_date":1342216018,"answer_id":11478817,"question_id":11473294,"body_markdown":"\r\n1) http://wiki.eclipse.org/Jetty/Howto/Configure_SSL\r\n\r\n2) http://git.codehaus.org/gitweb.cgi?p=jetty-project.git;a=tree;f=jetty-win32;h=e296255dc355f3abf37bf3f4faddfe383505416c;hb=HEAD\r\n\r\nYou'll need to adapt that for you particular usage, we stopped building it with release quite a while back because its license changed and the version we were using was getting crufty. Alternately take a look at the updated version of the tanuki stuff and if you can handle the license use that.\r\n","link":"http://stackoverflow.com/questions/11473294/jetty-v8-x-how-to-configure-enable-ssl-for-https-and-steps-to-create-windows/11478817#11478817","body":"<p>1) <a href=\"http://wiki.eclipse.org/Jetty/Howto/Configure_SSL\" rel=\"nofollow\">http://wiki.eclipse.org/Jetty/Howto/Configure_SSL</a></p>\n\n<p>2) <a href=\"http://git.codehaus.org/gitweb.cgi?p=jetty-project.git;a=tree;f=jetty-win32;h=e296255dc355f3abf37bf3f4faddfe383505416c;hb=HEAD\" rel=\"nofollow\">http://git.codehaus.org/gitweb.cgi?p=jetty-project.git;a=tree;f=jetty-win32;h=e296255dc355f3abf37bf3f4faddfe383505416c;hb=HEAD</a></p>\n\n<p>You'll need to adapt that for you particular usage, we stopped building it with release quite a while back because its license changed and the version we were using was getting crufty. Alternately take a look at the updated version of the tanuki stuff and if you can handle the license use that.</p>\n"}],"tags":["ssl","windows-services","web","jetty","maven-plugin"],"owner":{"reputation":11,"user_id":1523915,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/3b66d237299929f0f0468c363ad29017?s=128&d=identicon&r=PG","display_name":"Sandy Dalal","link":"http://stackoverflow.com/users/1523915/sandy-dalal"},"comment_count":0,"is_answered":false,"view_count":5482,"answer_count":1,"score":2,"last_activity_date":1414773417,"creation_date":1342192438,"last_edit_date":1343053146,"question_id":11473294,"body_markdown":"I have currently deployed a war file in my Jetty 8.x webapps container. I can start the Jetty server and connect to my server using HTTP. I want to be able to connect using HTTPS. What is the easiest way to enable HTTPS on Jetty 8.x? I am willing to use a self-signed certificate if necesssary. \r\n\r\nI need the following:\r\n\r\na) steps to generate and import cert into Jetty (preferably using a self-signed cert)\r\nb) configuration required in Jetty to support HTTPS / SSL\r\nc) command line parameters to start Jetty with SSL enabled\r\n\r\nSecondly, is anyone aware of how to turn Jetty 8.x so that it can be run as a Windows service?\r\n\r\nFor more details, I am running into problems enabling SSL on Jetty. I am trying to use a self signed cert for this purpose. I'm using keytool to create a keypair and self signed cert as follows:\r\n\r\nkeytool -genkey -alias domain -keyalg RSA -keysize 2048 -validity 365 -keystore keystore\r\n\r\nI then copy the keystore to my c:\\jetty\\etc directory. I edit the file 'jetty-ssl.xml' to make sure that the HTTPS port is set to 8443. When I restart the Jetty server, it seems to be listening on port 8443 and the startup sequence doesn't return any errors. However, when I try to connect using HTTPS, I get errors. Is there a prescribed method for generating a self signed cert and using this cert in the SSL configuration with Jetty?\r\n","link":"http://stackoverflow.com/questions/11473294/jetty-v8-x-how-to-configure-enable-ssl-for-https-and-steps-to-create-windows","title":"Jetty v8.x - How to Configure / Enable SSL for HTTPS and steps to create Windows Service","body":"<p>I have currently deployed a war file in my Jetty 8.x webapps container. I can start the Jetty server and connect to my server using HTTP. I want to be able to connect using HTTPS. What is the easiest way to enable HTTPS on Jetty 8.x? I am willing to use a self-signed certificate if necesssary. </p>\n\n<p>I need the following:</p>\n\n<p>a) steps to generate and import cert into Jetty (preferably using a self-signed cert)\nb) configuration required in Jetty to support HTTPS / SSL\nc) command line parameters to start Jetty with SSL enabled</p>\n\n<p>Secondly, is anyone aware of how to turn Jetty 8.x so that it can be run as a Windows service?</p>\n\n<p>For more details, I am running into problems enabling SSL on Jetty. I am trying to use a self signed cert for this purpose. I'm using keytool to create a keypair and self signed cert as follows:</p>\n\n<p>keytool -genkey -alias domain -keyalg RSA -keysize 2048 -validity 365 -keystore keystore</p>\n\n<p>I then copy the keystore to my c:\\jetty\\etc directory. I edit the file 'jetty-ssl.xml' to make sure that the HTTPS port is set to 8443. When I restart the Jetty server, it seems to be listening on port 8443 and the startup sequence doesn't return any errors. However, when I try to connect using HTTPS, I get errors. Is there a prescribed method for generating a self signed cert and using this cert in the SSL configuration with Jetty?</p>\n"},{"answers":[{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"comments":[{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"edited":false,"score":0,"creation_date":1365221777,"post_id":15846934,"comment_id":22550772},{"owner":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"edited":false,"score":0,"creation_date":1365221907,"post_id":15846934,"comment_id":22550799},{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"reply_to_user":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"edited":false,"score":0,"creation_date":1365222180,"post_id":15846934,"comment_id":22550842},{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"reply_to_user":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"edited":false,"score":0,"creation_date":1365222547,"post_id":15846934,"comment_id":22550893},{"owner":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"edited":false,"score":0,"creation_date":1365224712,"post_id":15846934,"comment_id":22551194},{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"reply_to_user":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"edited":false,"score":0,"creation_date":1365225150,"post_id":15846934,"comment_id":22551271},{"owner":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"edited":false,"score":0,"creation_date":1365225521,"post_id":15846934,"comment_id":22551340},{"owner":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"reply_to_user":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"edited":false,"score":0,"creation_date":1365225616,"post_id":15846934,"comment_id":22551355},{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"reply_to_user":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"edited":false,"score":0,"creation_date":1365225735,"post_id":15846934,"comment_id":22551385},{"owner":{"reputation":243,"user_id":1421379,"user_type":"registered","accept_rate":20,"profile_image":"https://www.gravatar.com/avatar/75fe583f071ca51f6ec29aca635f3c22?s=128&d=identicon&r=PG","display_name":"L K","link":"http://stackoverflow.com/users/1421379/l-k"},"edited":false,"score":0,"creation_date":1378907543,"post_id":15846934,"comment_id":27624201},{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"edited":false,"score":0,"creation_date":1379060514,"post_id":15846934,"comment_id":27691408}],"last_editor":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"comment_count":11,"is_accepted":false,"score":-1,"last_activity_date":1365224281,"last_edit_date":1365224281,"creation_date":1365221597,"answer_id":15846934,"question_id":15846864,"body_markdown":"In gridview you have to define an event `onselectedindexchanged` and `onrowdatabound` as below:\r\n\r\n onselectedindexchanged="GridView1_SelectedIndexChanged" onrowdatabound="GridView1_RowDataBound" \r\n\r\n**to show the selected row you can use following style in your grid view:**\r\n\r\n <SelectedRowStyle BackColor="Red" />\r\n\r\n**in code behind:**\r\n\r\n protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)\r\n {\r\n }\r\n\r\n protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)\r\n {\r\n\r\n if (e.Row.RowType == DataControlRowType.DataRow)\r\n {\r\n // Set the hand mouse cursor for the selected row.\r\n e.Row.Attributes.Add("OnMouseOver", "this.style.cursor = 'hand';");\r\n\r\n // The seelctButton exists for ensuring the selection functionality\r\n // and bind it with the appropriate event hanlder.\r\n LinkButton selectButton = new LinkButton()\r\n {\r\n CommandName = "Select",\r\n Text = e.Row.Cells[0].Text\r\n };\r\n selectButton.Font.Underline = false;\r\n selectButton.ForeColor = Color.Black;\r\n\r\n e.Row.Cells[0].Controls.Add(selectButton);\r\n //e.Row.Attributes["OnClick"] =\r\n // Page.ClientScript.GetPostBackClientHyperlink(selectButton, "");\r\n e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex);\r\n }\r\n }\r\n**note:** you can find the event in event window. ","link":"http://stackoverflow.com/questions/15846864/asp-net-gridview-enabling-row-selection/15846934#15846934","body":"<p>In gridview you have to define an event <code>onselectedindexchanged</code> and <code>onrowdatabound</code> as below:</p>\n\n<pre><code>onselectedindexchanged=\"GridView1_SelectedIndexChanged\" onrowdatabound=\"GridView1_RowDataBound\" \n</code></pre>\n\n<p><strong>to show the selected row you can use following style in your grid view:</strong></p>\n\n<pre><code> <SelectedRowStyle BackColor=\"Red\" />\n</code></pre>\n\n<p><strong>in code behind:</strong></p>\n\n<pre><code>protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)\n{\n}\n\nprotected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)\n{\n\nif (e.Row.RowType == DataControlRowType.DataRow)\n {\n // Set the hand mouse cursor for the selected row.\n e.Row.Attributes.Add(\"OnMouseOver\", \"this.style.cursor = 'hand';\");\n\n // The seelctButton exists for ensuring the selection functionality\n // and bind it with the appropriate event hanlder.\n LinkButton selectButton = new LinkButton()\n {\n CommandName = \"Select\",\n Text = e.Row.Cells[0].Text\n };\n selectButton.Font.Underline = false;\n selectButton.ForeColor = Color.Black;\n\n e.Row.Cells[0].Controls.Add(selectButton);\n //e.Row.Attributes[\"OnClick\"] =\n // Page.ClientScript.GetPostBackClientHyperlink(selectButton, \"\");\n e.Row.Attributes[\"onclick\"] = ClientScript.GetPostBackClientHyperlink(this.GridView1, \"Select$\" + e.Row.RowIndex);\n }\n }\n</code></pre>\n\n<p><strong>note:</strong> you can find the event in event window. </p>\n"},{"owner":{"reputation":88,"user_id":1280840,"user_type":"registered","accept_rate":79,"profile_image":"https://www.gravatar.com/avatar/9b82e77b6f30e662a608503adaef33bb?s=128&d=identicon&r=PG","display_name":"user1280840","link":"http://stackoverflow.com/users/1280840/user1280840"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1393235291,"creation_date":1393235291,"answer_id":21984059,"question_id":15846864,"body_markdown":"I think the MultiSelect and SelectionMode properties are only available with the VB.NET grid, not in ASP.NET. Bear in mind that all controls in ASP.NET are HTML-in-disguise, so they may be more limited. There is no reason why you can't have a multi-select table, but you have to do the plumbing yourself. So you need to enable row selection, either by handling the RowDataBound event as in\r\n\r\nhttp://forums.asp.net/t/992062.aspx?How+to+select+row+in+gridview+on+click\r\n\r\nor else using the MS-provided option as in\r\n\r\nhttp://msdn.microsoft.com/en-us/library/wbk82279(v=vs.100).aspx\r\n\r\nThen you need to handle the SelectedIndexChanging event, figure out which row the user clicked on, and handle the row-colouring yourself.","link":"http://stackoverflow.com/questions/15846864/asp-net-gridview-enabling-row-selection/21984059#21984059","body":"<p>I think the MultiSelect and SelectionMode properties are only available with the VB.NET grid, not in ASP.NET. Bear in mind that all controls in ASP.NET are HTML-in-disguise, so they may be more limited. There is no reason why you can't have a multi-select table, but you have to do the plumbing yourself. So you need to enable row selection, either by handling the RowDataBound event as in</p>\n\n<p><a href=\"http://forums.asp.net/t/992062.aspx?How+to+select+row+in+gridview+on+click\" rel=\"nofollow\">http://forums.asp.net/t/992062.aspx?How+to+select+row+in+gridview+on+click</a></p>\n\n<p>or else using the MS-provided option as in</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library/wbk82279(v=vs.100).aspx\" rel=\"nofollow\">http://msdn.microsoft.com/en-us/library/wbk82279(v=vs.100).aspx</a></p>\n\n<p>Then you need to handle the SelectedIndexChanging event, figure out which row the user clicked on, and handle the row-colouring yourself.</p>\n"}],"tags":["asp.net","gridview"],"owner":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"comments":[{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"edited":false,"score":0,"creation_date":1365222954,"post_id":15846864,"comment_id":22550950},{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"edited":false,"score":0,"creation_date":1365223369,"post_id":15846864,"comment_id":22550996},{"owner":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"reply_to_user":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"edited":false,"score":0,"creation_date":1365223531,"post_id":15846864,"comment_id":22551021},{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"edited":false,"score":0,"creation_date":1365223587,"post_id":15846864,"comment_id":22551029},{"owner":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"reply_to_user":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"edited":false,"score":0,"creation_date":1365223677,"post_id":15846864,"comment_id":22551042},{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"edited":false,"score":0,"creation_date":1365224325,"post_id":15846864,"comment_id":22551141}],"comment_count":6,"is_answered":false,"view_count":10711,"answer_count":2,"score":0,"last_activity_date":1414773417,"creation_date":1365220696,"last_edit_date":1365223257,"question_id":15846864,"body_markdown":"I am using GridView in asp.net. I want to select a single data row. I looked for MultiSelect and SelectionMode in property panel, but I can't find it. \r\n\r\nSo how to enable selecting rows in GridView? \r\n\r\nThanks.\r\n\r\n![enter image description here][1]\r\n [1]: http://i.stack.imgur.com/6jJ7Q.jpg\r\n\r\nCode Behind\r\n\r\n public partial class SearchCourse : System.Web.UI.Page\r\n {\r\n Connection dbCon;\r\n DataTable tbl;\r\n\r\n protected void Page_Load(object sender, EventArgs e)\r\n {\r\n dbCon = new Connection();\r\n \r\n \r\n }\r\n protected void RadioButton1_CheckedChanged(object sender, EventArgs e)\r\n {\r\n if (RadioButton1.Checked) {\r\n txtSubName.Enabled = true;\r\n comboSemester.Enabled = false;\r\n comboYear.Enabled = false;\r\n comboProgram.Enabled =false;\r\n txtSubName.Text = "";\r\n }\r\n }\r\n protected void RadioButton2_CheckedChanged(object sender, EventArgs e)\r\n {\r\n if (RadioButton2.Checked) {\r\n\r\n comboProgram.Enabled = true;\r\n\r\n if (comboProgram.SelectedItem.ToString() == "Foundation Course")\r\n {\r\n comboSemester.Enabled = false;\r\n comboYear.Enabled = false;\r\n }\r\n else {\r\n comboSemester.Enabled = true;\r\n comboYear.Enabled = true;\r\n }\r\n txtSubName.Text = "";\r\n txtSubName.Enabled = false;\r\n }\r\n }\r\n\r\n protected void imgBtnSearch_Click(object sender, ImageClickEventArgs e)\r\n {\r\n if (RadioButton1.Checked) {\r\n String name = txtSubName.Text;\r\n tbl = dbCon.getResultsBySubjectName(name);\r\n GridView1.DataSource = tbl;\r\n GridView1.DataBind();\r\n }\r\n else if (RadioButton2.Checked)\r\n {\r\n String program = comboProgram.SelectedItem.ToString();\r\n String year = comboYear.SelectedItem.ToString();\r\n String sem= comboSemester.SelectedItem.ToString();\r\n tbl = dbCon.getResultsByProgram(program,year,sem);\r\n GridView1.DataSource = tbl;\r\n GridView1.DataBind();\r\n }\r\n else if (RadioButton3.Checked)\r\n {\r\n String name = txtSubName.Text;\r\n tbl = dbCon.getResultsBySubjectNo(name);\r\n GridView1.DataSource = tbl;\r\n GridView1.DataBind();\r\n }\r\n \r\n }\r\n\r\n protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)\r\n {\r\n String program = comboProgram.SelectedItem.ToString();\r\n String year, sem;\r\n if (program == "Foundation Course")\r\n {\r\n comboYear.Enabled = false;\r\n comboSemester.Enabled = false;\r\n year = null;\r\n sem = null;\r\n }\r\n else {\r\n comboYear.Enabled = true;\r\n comboSemester.Enabled = true;\r\n year = comboYear.SelectedItem.ToString();\r\n sem = comboSemester.SelectedItem.ToString();\r\n }\r\n\r\n tbl = dbCon.getResultsByProgram(program, year, sem);\r\n GridView1.DataSource = tbl;\r\n GridView1.DataBind();\r\n }\r\n\r\n protected void comboYear_SelectedIndexChanged(object sender, EventArgs e)\r\n {\r\n String program = comboProgram.SelectedItem.ToString();\r\n String year = comboYear.SelectedItem.ToString();\r\n String sem = comboSemester.SelectedItem.ToString();\r\n tbl = dbCon.getResultsByProgram(program, year, sem);\r\n GridView1.DataSource = tbl;\r\n GridView1.DataBind();\r\n }\r\n protected void comboSemester_SelectedIndexChanged(object sender, EventArgs e)\r\n {\r\n String program = comboProgram.SelectedItem.ToString();\r\n String year = comboYear.SelectedItem.ToString();\r\n String sem = comboSemester.SelectedItem.ToString();\r\n tbl = dbCon.getResultsByProgram(program, year, sem);\r\n GridView1.DataSource = tbl;\r\n GridView1.DataBind();\r\n \r\n }\r\n\r\n\r\n \r\n protected void RadioButton3_CheckedChanged(object sender, EventArgs e)\r\n {\r\n if (RadioButton3.Checked)\r\n {\r\n txtSubName.Enabled = true;\r\n comboSemester.Enabled = false;\r\n comboYear.Enabled = false;\r\n comboProgram.Enabled = false;\r\n txtSubName.Text = "";\r\n }\r\n }\r\n protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)\r\n {\r\n \r\n }\r\n}\r\n\r\n**GridView Code** \r\n\r\n <asp:GridView ID="GridView1" CssClass="grid" runat="server" AllowPaging="True" \r\n BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" \r\n GridLines="Horizontal" EnableViewState="False" \r\n PageSize="5" onselectedindexchanged="GridView1_SelectedIndexChanged" >\r\n \r\n <HeaderStyle ForeColor="White" />\r\n \r\n <RowStyle CssClass="gridRow" Width="800px" />\r\n \r\n <SelectedRowStyle BackColor="#FF0066" ForeColor="White" />\r\n \r\n </asp:GridView> ","link":"http://stackoverflow.com/questions/15846864/asp-net-gridview-enabling-row-selection","title":"Asp.net GridView Enabling row selection","body":"<p>I am using GridView in asp.net. I want to select a single data row. I looked for MultiSelect and SelectionMode in property panel, but I can't find it. </p>\n\n<p>So how to enable selecting rows in GridView? </p>\n\n<p>Thanks.</p>\n\n<p><img src=\"http://i.stack.imgur.com/6jJ7Q.jpg\" alt=\"enter image description here\">\nCode Behind</p>\n\n<pre><code>public partial class SearchCourse : System.Web.UI.Page\n{\nConnection dbCon;\nDataTable tbl;\n\nprotected void Page_Load(object sender, EventArgs e)\n{\n dbCon = new Connection();\n\n\n}\nprotected void RadioButton1_CheckedChanged(object sender, EventArgs e)\n{\n if (RadioButton1.Checked) {\n txtSubName.Enabled = true;\n comboSemester.Enabled = false;\n comboYear.Enabled = false;\n comboProgram.Enabled =false;\n txtSubName.Text = \"\";\n }\n}\nprotected void RadioButton2_CheckedChanged(object sender, EventArgs e)\n{\n if (RadioButton2.Checked) {\n\n comboProgram.Enabled = true;\n\n if (comboProgram.SelectedItem.ToString() == \"Foundation Course\")\n {\n comboSemester.Enabled = false;\n comboYear.Enabled = false;\n }\n else {\n comboSemester.Enabled = true;\n comboYear.Enabled = true;\n }\n txtSubName.Text = \"\";\n txtSubName.Enabled = false;\n }\n}\n\nprotected void imgBtnSearch_Click(object sender, ImageClickEventArgs e)\n{\n if (RadioButton1.Checked) {\n String name = txtSubName.Text;\n tbl = dbCon.getResultsBySubjectName(name);\n GridView1.DataSource = tbl;\n GridView1.DataBind();\n }\n else if (RadioButton2.Checked)\n {\n String program = comboProgram.SelectedItem.ToString();\n String year = comboYear.SelectedItem.ToString();\n String sem= comboSemester.SelectedItem.ToString();\n tbl = dbCon.getResultsByProgram(program,year,sem);\n GridView1.DataSource = tbl;\n GridView1.DataBind();\n }\n else if (RadioButton3.Checked)\n {\n String name = txtSubName.Text;\n tbl = dbCon.getResultsBySubjectNo(name);\n GridView1.DataSource = tbl;\n GridView1.DataBind();\n }\n\n}\n\nprotected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)\n{\n String program = comboProgram.SelectedItem.ToString();\n String year, sem;\n if (program == \"Foundation Course\")\n {\n comboYear.Enabled = false;\n comboSemester.Enabled = false;\n year = null;\n sem = null;\n }\n else {\n comboYear.Enabled = true;\n comboSemester.Enabled = true;\n year = comboYear.SelectedItem.ToString();\n sem = comboSemester.SelectedItem.ToString();\n }\n\n tbl = dbCon.getResultsByProgram(program, year, sem);\n GridView1.DataSource = tbl;\n GridView1.DataBind();\n}\n\nprotected void comboYear_SelectedIndexChanged(object sender, EventArgs e)\n{\n String program = comboProgram.SelectedItem.ToString();\n String year = comboYear.SelectedItem.ToString();\n String sem = comboSemester.SelectedItem.ToString();\n tbl = dbCon.getResultsByProgram(program, year, sem);\n GridView1.DataSource = tbl;\n GridView1.DataBind();\n}\nprotected void comboSemester_SelectedIndexChanged(object sender, EventArgs e)\n{\n String program = comboProgram.SelectedItem.ToString();\n String year = comboYear.SelectedItem.ToString();\n String sem = comboSemester.SelectedItem.ToString();\n tbl = dbCon.getResultsByProgram(program, year, sem);\n GridView1.DataSource = tbl;\n GridView1.DataBind();\n\n}\n\n\n\nprotected void RadioButton3_CheckedChanged(object sender, EventArgs e)\n{\n if (RadioButton3.Checked)\n {\n txtSubName.Enabled = true;\n comboSemester.Enabled = false;\n comboYear.Enabled = false;\n comboProgram.Enabled = false;\n txtSubName.Text = \"\";\n }\n}\nprotected void GridView1_SelectedIndexChanged(object sender, EventArgs e)\n{\n\n}\n</code></pre>\n\n<p>}</p>\n\n<p><strong>GridView Code</strong> </p>\n\n<pre><code><asp:GridView ID=\"GridView1\" CssClass=\"grid\" runat=\"server\" AllowPaging=\"True\" \nBorderColor=\"Black\" BorderStyle=\"Solid\" BorderWidth=\"2px\" \nGridLines=\"Horizontal\" EnableViewState=\"False\" \nPageSize=\"5\" onselectedindexchanged=\"GridView1_SelectedIndexChanged\" >\n</code></pre>\n\n<p></p>\n\n<pre><code><RowStyle CssClass=\"gridRow\" Width=\"800px\" />\n\n<SelectedRowStyle BackColor=\"#FF0066\" ForeColor=\"White\" />\n\n</asp:GridView> \n</code></pre>\n"},{"answers":[{"owner":{"reputation":2958,"user_id":1161743,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/18aebb65726f793706e6bba28e921420?s=128&d=identicon&r=PG","display_name":"Jonathan Lin","link":"http://stackoverflow.com/users/1161743/jonathan-lin"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1386680460,"creation_date":1386680460,"answer_id":20495291,"question_id":20495112,"body_markdown":"In each of your `KFZFragment`, `LogFragment`, and `TrackFragment`, you should be able to override `onResume` in your fragment class and put your necessary refresh/reload code there.","link":"http://stackoverflow.com/questions/20495112/how-to-refresh-a-fragment-in-a-viewpager/20495291#20495291","body":"<p>In each of your <code>KFZFragment</code>, <code>LogFragment</code>, and <code>TrackFragment</code>, you should be able to override <code>onResume</code> in your fragment class and put your necessary refresh/reload code there.</p>\n"},{"owner":{"reputation":76,"user_id":1806231,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/3f432d5ca5a2d177e9c4a89ffaf55606?s=128&d=identicon&r=PG","display_name":"user1806231","link":"http://stackoverflow.com/users/1806231/user1806231"},"comments":[{"owner":{"reputation":3176,"user_id":1501613,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/a917ec0fd44810a1c18dac1822198994?s=128&d=identicon&r=PG&f=1","display_name":"cYrixmorten","link":"http://stackoverflow.com/users/1501613/cyrixmorten"},"edited":false,"score":0,"creation_date":1386682879,"post_id":20495692,"comment_id":30635018}],"comment_count":1,"is_accepted":false,"score":0,"last_activity_date":1386681583,"creation_date":1386681583,"answer_id":20495692,"question_id":20495112,"body_markdown":"Why not? use static methods to refresh the data ","link":"http://stackoverflow.com/questions/20495112/how-to-refresh-a-fragment-in-a-viewpager/20495692#20495692","body":"<p>Why not? use static methods to refresh the data </p>\n"},{"owner":{"reputation":3176,"user_id":1501613,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/a917ec0fd44810a1c18dac1822198994?s=128&d=identicon&r=PG&f=1","display_name":"cYrixmorten","link":"http://stackoverflow.com/users/1501613/cyrixmorten"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1386681623,"creation_date":1386681623,"answer_id":20495703,"question_id":20495112,"body_markdown":"I agree with Jonathan Lin\r\n\r\nBut if the fragment you want to update is the fragment that is currently shown you can do something similar to this:\r\n\r\n public class DisplayPagerAdapter extends FragmentPagerAdapter {\r\n\t\r\n private static final String TAG = "DisplayPagerAdapter";\r\n \r\n\tSparseArray<DisplayFragment> registeredFragments = new SparseArray<DisplayFragment>();\r\n\r\n public DisplayPagerAdapter(FragmentManager fm) {\r\n super(fm);\r\n }\r\n\r\n @Override\r\n public int getCount() {\r\n \tDisplayCoreModule display = DisplayCoreModule.getInstance();\r\n return (display != null && display.getPagesCount() > 0) ? display.getPagesCount() : 1;\r\n }\r\n \r\n @Override\r\n public int getItemPosition(Object object) {\r\n return POSITION_NONE;\r\n }\r\n \r\n\r\n @Override\r\n public Fragment getItem(int position) {\r\n \tLog.d(TAG, "getItem " + position);\r\n return DisplayFragment.newInstance(position); \r\n }\r\n\r\n @Override\r\n public CharSequence getPageTitle(int position) {\r\n \tDisplayCoreModule display = DisplayCoreModule.getInstance();\r\n \tif (display != null && display.getPagesCount() > 0) {\r\n \t\treturn "Side " + (position+1);\r\n \t} else {\r\n \t\treturn super.getPageTitle(position);\r\n \t}\r\n }\r\n \r\n @Override\r\n public Object instantiateItem(ViewGroup container, int position) {\r\n \tLog.d(TAG, "instantiateItem " + position);\r\n \tDisplayFragment fragment = (DisplayFragment) super.instantiateItem(container, position);\r\n registeredFragments.put(position, fragment);\r\n return fragment;\r\n }\r\n\r\n @Override\r\n public void destroyItem(ViewGroup container, int position, Object object) {\r\n \tLog.d(TAG, "destroyItem " + position);\r\n registeredFragments.remove(position);\r\n super.destroyItem(container, position, object);\r\n }\r\n\r\n public Fragment getRegisteredFragment(int position) {\r\n return registeredFragments.get(position);\r\n }\r\n \r\n public SparseArray<DisplayFragment> getRegisteredFragments() {\r\n return registeredFragments;\r\n }\r\n\r\n }\r\n\r\nIt is the registeredFragments part that I wanted to show you.\r\n\r\nSince you use FragmentPagerAdapter then getRegisteredFragment(int position) will always return one of your fragments given that you provide a valid position. Should you change to FragmentStatePagerAdapter at some point, it can return null on some of the positions.\r\n\r\nNow, in TrackFragment create a callback to your MainActivity, which then informs LogFragment, shown here in pseudo code:\r\n\r\n Fragment TrackFragment {\r\n \r\n interface TrackFragmentCallback() {\r\n public void newInfo()\r\n }\r\n\r\n TrackFragmentCallback trackFragmentCallback;\r\n\r\n onAttatch() {\r\n // make sure to implement TrackFragmentCallback on MainActivity \r\n trackFragmentCallback = (TrackFragmentCallback)getActivity();\r\n } \r\n\r\n // When this fragment has new info, simply do:\r\n trackFragmentCallback.newInfo();\r\n }\r\n\r\n MainActivity implements TrackFragmentCallback {\r\n\r\n newInfo() {\r\n // get LogFragment\r\n LogFragment logFragment = pagerAdapter.getRegisteredFragment(1); \r\n if (logFragment != null) {\r\n logFragment.update();\r\n }\r\n }\r\n }\r\n\r\n\r\nHope this helps.","link":"http://stackoverflow.com/questions/20495112/how-to-refresh-a-fragment-in-a-viewpager/20495703#20495703","body":"<p>I agree with Jonathan Lin</p>\n\n<p>But if the fragment you want to update is the fragment that is currently shown you can do something similar to this:</p>\n\n<pre><code>public class DisplayPagerAdapter extends FragmentPagerAdapter {\n\nprivate static final String TAG = \"DisplayPagerAdapter\";\n\nSparseArray<DisplayFragment> registeredFragments = new SparseArray<DisplayFragment>();\n\npublic DisplayPagerAdapter(FragmentManager fm) {\n super(fm);\n}\n\n@Override\npublic int getCount() {\n DisplayCoreModule display = DisplayCoreModule.getInstance();\n return (display != null && display.getPagesCount() > 0) ? display.getPagesCount() : 1;\n}\n\n@Override\npublic int getItemPosition(Object object) {\n return POSITION_NONE;\n}\n\n\n@Override\npublic Fragment getItem(int position) {\n Log.d(TAG, \"getItem \" + position);\n return DisplayFragment.newInstance(position); \n}\n\n@Override\npublic CharSequence getPageTitle(int position) {\n DisplayCoreModule display = DisplayCoreModule.getInstance();\n if (display != null && display.getPagesCount() > 0) {\n return \"Side \" + (position+1);\n } else {\n return super.getPageTitle(position);\n }\n}\n\n@Override\npublic Object instantiateItem(ViewGroup container, int position) {\n Log.d(TAG, \"instantiateItem \" + position);\n DisplayFragment fragment = (DisplayFragment) super.instantiateItem(container, position);\n registeredFragments.put(position, fragment);\n return fragment;\n}\n\n@Override\npublic void destroyItem(ViewGroup container, int position, Object object) {\n Log.d(TAG, \"destroyItem \" + position);\n registeredFragments.remove(position);\n super.destroyItem(container, position, object);\n}\n\npublic Fragment getRegisteredFragment(int position) {\n return registeredFragments.get(position);\n}\n\npublic SparseArray<DisplayFragment> getRegisteredFragments() {\n return registeredFragments;\n}\n\n}\n</code></pre>\n\n<p>It is the registeredFragments part that I wanted to show you.</p>\n\n<p>Since you use FragmentPagerAdapter then getRegisteredFragment(int position) will always return one of your fragments given that you provide a valid position. Should you change to FragmentStatePagerAdapter at some point, it can return null on some of the positions.</p>\n\n<p>Now, in TrackFragment create a callback to your MainActivity, which then informs LogFragment, shown here in pseudo code:</p>\n\n<pre><code>Fragment TrackFragment {\n\n interface TrackFragmentCallback() {\n public void newInfo()\n }\n\n TrackFragmentCallback trackFragmentCallback;\n\n onAttatch() {\n // make sure to implement TrackFragmentCallback on MainActivity \n trackFragmentCallback = (TrackFragmentCallback)getActivity();\n } \n\n // When this fragment has new info, simply do:\n trackFragmentCallback.newInfo();\n}\n\nMainActivity implements TrackFragmentCallback {\n\n newInfo() {\n // get LogFragment\n LogFragment logFragment = pagerAdapter.getRegisteredFragment(1); \n if (logFragment != null) {\n logFragment.update();\n }\n }\n}\n</code></pre>\n\n<p>Hope this helps.</p>\n"}],"tags":["android","android-fragments","android-viewpager"],"owner":{"reputation":135,"user_id":2940365,"user_type":"registered","accept_rate":67,"profile_image":"https://www.gravatar.com/avatar/692463659bb2037320958e5d3dcaf628?s=128&d=identicon&r=PG&f=1","display_name":"aut_silvia","link":"http://stackoverflow.com/users/2940365/aut-silvia"},"comment_count":0,"is_answered":false,"view_count":7048,"answer_count":3,"score":0,"last_activity_date":1414773417,"creation_date":1386679957,"question_id":20495112,"body_markdown":"I know there are already some questions to this problem. But I am really new in Android and ecspecially to `Fragments` and `Viewpager`. Pls have passion with me. I didn't found a answer which fits to my code.\r\n\r\nI dont know how to refresh a fragment or reload it when it's "active" again.\r\n\r\n**TabsPagerAdapter.java:**\r\n\r\n public class TabsPagerAdapter extends FragmentPagerAdapter{\r\n \r\n \t\r\n \tpublic TabsPagerAdapter(FragmentManager fm){\r\n \t\tsuper(fm);\r\n \t}\r\n \r\n \t@Override\r\n \tpublic Fragment getItem(int index) {\r\n \t\t\r\n \t\tswitch (index) {\r\n case 0:\r\n \r\n return new KFZFragment();\r\n case 1:\r\n \r\n return new LogFragment();\r\n case 2:\r\n \r\n return new TrackFragment();\r\n }\r\n \r\n return null;\r\n \t}\r\n \t\r\n \t@Override\r\n \tpublic int getCount() {\r\n \t\t// get item count - equal to number of tabs\r\n \t\treturn 3;\r\n \t}\r\n \r\n }\r\n\r\nI have this 3 Fragments (`KFZFragment,LogFragment,TrackFragment`) and on the `TrackFragment` I calculate some data and this data should be display in a ListView in `LogFragment`.\r\nBut when I change to LogFragment it's not the latest data. So it doesnt refresh.\r\n\r\nNow how should I modify my code to refresh the fragments when it's "active"?\r\n\r\n\r\n**MainActivityFragment.java:**\r\n\r\n public class MainActivityFragment extends FragmentActivity implements ActionBar.TabListener{\r\n \r\n \tprivate ViewPager viewPager;\r\n private TabsPagerAdapter mAdapter;\r\n private ActionBar actionBar;\r\n List<Fragment> fragments;\r\n \r\n private String[] tabs = { "KFZ", "Fahrten Log", "Kosten Track" };\r\n \r\n @Override\r\n protected void onCreate(Bundle savedInstanceState) {\r\n super.onCreate(savedInstanceState);\r\n setContentView(R.layout.activity_main_fragment);\r\n \r\n // Initilization\r\n viewPager = (ViewPager) findViewById(R.id.pager);\r\n actionBar = getActionBar();\r\n mAdapter = new TabsPagerAdapter(getSupportFragmentManager());\r\n \r\n fragments = new Vector<Fragment>();\r\n fragments.add(Fragment.instantiate(this, KFZFragment.class.getName(),savedInstanceState));\r\n fragments.add(Fragment.instantiate(this, LogFragment.class.getName(),savedInstanceState));\r\n \r\n viewPager.setAdapter(mAdapter);\r\n actionBar.setHomeButtonEnabled(false);\r\n actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); \r\n \r\n // Adding Tabs\r\n for (String tab_name : tabs) {\r\n actionBar.addTab(actionBar.newTab().setText(tab_name)\r\n .setTabListener(this));\r\n }\r\n \r\n viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {\r\n \t \r\n @Override\r\n public void onPageSelected(int position) {\r\n // on changing the page\r\n // make respected tab selected\r\n actionBar.setSelectedNavigationItem(position);\r\n \r\n }\r\n \r\n @Override\r\n public void onPageScrolled(int arg0, float arg1, int arg2) {\r\n }\r\n \r\n @Override\r\n public void onPageScrollStateChanged(int arg0) {\r\n }\r\n });\r\n } \r\n \t@Override\r\n \tpublic void onTabReselected(Tab tab, FragmentTransaction ft) {\r\n \t\t// TODO Auto-generated method stub\r\n \t\t\r\n \t}\r\n \r\n \t@Override\r\n \tpublic void onTabSelected(Tab tab, FragmentTransaction ft) {\r\n \t\tviewPager.setCurrentItem(tab.getPosition());\r\n \t\t\r\n \t}\r\n \r\n \t@Override\r\n \tpublic void onTabUnselected(Tab tab, FragmentTransaction ft) {\r\n \t\t// TODO Auto-generated method stub\r\n \t\t\r\n \t}\r\n \t\r\n \t@Override\r\n \tpublic boolean onKeyDown(int keyCode, KeyEvent event) {\r\n \t if (keyCode == KeyEvent.KEYCODE_BACK) {\r\n \r\n \t \r\n \t }\r\n \t return super.onKeyDown(keyCode, event);\r\n \t}\r\n \r\n }\r\n\r\nPls help me out.","link":"http://stackoverflow.com/questions/20495112/how-to-refresh-a-fragment-in-a-viewpager","title":"How to refresh a fragment in a viewpager?","body":"<p>I know there are already some questions to this problem. But I am really new in Android and ecspecially to <code>Fragments</code> and <code>Viewpager</code>. Pls have passion with me. I didn't found a answer which fits to my code.</p>\n\n<p>I dont know how to refresh a fragment or reload it when it's \"active\" again.</p>\n\n<p><strong>TabsPagerAdapter.java:</strong></p>\n\n<pre><code>public class TabsPagerAdapter extends FragmentPagerAdapter{\n\n\n public TabsPagerAdapter(FragmentManager fm){\n super(fm);\n }\n\n @Override\n public Fragment getItem(int index) {\n\n switch (index) {\n case 0:\n\n return new KFZFragment();\n case 1:\n\n return new LogFragment();\n case 2:\n\n return new TrackFragment();\n }\n\n return null;\n }\n\n @Override\n public int getCount() {\n // get item count - equal to number of tabs\n return 3;\n }\n\n}\n</code></pre>\n\n<p>I have this 3 Fragments (<code>KFZFragment,LogFragment,TrackFragment</code>) and on the <code>TrackFragment</code> I calculate some data and this data should be display in a ListView in <code>LogFragment</code>.\nBut when I change to LogFragment it's not the latest data. So it doesnt refresh.</p>\n\n<p>Now how should I modify my code to refresh the fragments when it's \"active\"?</p>\n\n<p><strong>MainActivityFragment.java:</strong></p>\n\n<pre><code>public class MainActivityFragment extends FragmentActivity implements ActionBar.TabListener{\n\n private ViewPager viewPager;\n private TabsPagerAdapter mAdapter;\n private ActionBar actionBar;\n List<Fragment> fragments;\n\n private String[] tabs = { \"KFZ\", \"Fahrten Log\", \"Kosten Track\" };\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main_fragment);\n\n // Initilization\n viewPager = (ViewPager) findViewById(R.id.pager);\n actionBar = getActionBar();\n mAdapter = new TabsPagerAdapter(getSupportFragmentManager());\n\n fragments = new Vector<Fragment>();\n fragments.add(Fragment.instantiate(this, KFZFragment.class.getName(),savedInstanceState));\n fragments.add(Fragment.instantiate(this, LogFragment.class.getName(),savedInstanceState));\n\n viewPager.setAdapter(mAdapter);\n actionBar.setHomeButtonEnabled(false);\n actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); \n\n // Adding Tabs\n for (String tab_name : tabs) {\n actionBar.addTab(actionBar.newTab().setText(tab_name)\n .setTabListener(this));\n }\n\n viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {\n\n @Override\n public void onPageSelected(int position) {\n // on changing the page\n // make respected tab selected\n actionBar.setSelectedNavigationItem(position);\n\n }\n\n @Override\n public void onPageScrolled(int arg0, float arg1, int arg2) {\n }\n\n @Override\n public void onPageScrollStateChanged(int arg0) {\n }\n });\n } \n @Override\n public void onTabReselected(Tab tab, FragmentTransaction ft) {\n // TODO Auto-generated method stub\n\n }\n\n @Override\n public void onTabSelected(Tab tab, FragmentTransaction ft) {\n viewPager.setCurrentItem(tab.getPosition());\n\n }\n\n @Override\n public void onTabUnselected(Tab tab, FragmentTransaction ft) {\n // TODO Auto-generated method stub\n\n }\n\n @Override\n public boolean onKeyDown(int keyCode, KeyEvent event) {\n if (keyCode == KeyEvent.KEYCODE_BACK) {\n\n\n }\n return super.onKeyDown(keyCode, event);\n }\n\n}\n</code></pre>\n\n<p>Pls help me out.</p>\n"},{"tags":["ios","cordova","phonecalls"],"owner":{"reputation":23,"user_id":939075,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/25489fce3562ca05a170ca3846233f2b?s=128&d=identicon&r=PG","display_name":"Rodrigo Gil","link":"http://stackoverflow.com/users/939075/rodrigo-gil"},"comment_count":0,"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1414773414,"creation_date":1414773414,"question_id":26679416,"body_markdown":"I need to start a telephone call and I am using this code (that works perfectly):\r\n\r\n NSString *phoneCallNum = [NSString stringWithFormat:@"tel://%@",phoneNumber];\r\n\r\n [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneCallNum]];\r\n\r\nBut I need to check if the call was connected or simply the call ended without connect.\r\n\r\nI found that Core Telephony notifies this using something like:\r\n\r\n [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callConnected:) name:CTCallStateConnected\r\n object:[UIApplication sharedApplication]];\r\n \r\n [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callEnded:) name:CTCallStateDisconnected object:[UIApplication sharedApplication]];\r\n\r\nSo how can I link both? I tried this code:\r\n\r\n - (void)callNumber:(CDVInvokedUrlCommand*)command\r\n {\r\n CDVPluginResult* pluginResult = nil;\r\n NSString* phoneNumber = [command.arguments objectAtIndex:0];\r\n \r\n self.callbackID = command.callbackId;\r\n \r\n [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callConnected:) name:CTCallStateConnected\r\n object:[UIApplication sharedApplication]];\r\n \r\n [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callEnded:) name:CTCallStateDisconnected object:[UIApplication sharedApplication]];\r\n \r\n NSString *phoneCallNum = [NSString stringWithFormat:@"tel://%@",phoneNumber];\r\n\r\n [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneCallNum]];\r\n\r\n NSLog(@"phone btn touch %@", phoneCallNum);\r\n }\r\n\r\n - (void) callConnected: (NSNotification *)notification\r\n {\r\n BOOL succeeded = YES;\r\n NSLog(@"Call connected");\r\n }\r\n\r\nThanks in advance,\r\n\r\nRodrigo.","link":"http://stackoverflow.com/questions/26679416/check-if-a-call-was-connected-on-ios","title":"check if a call was connected on iOS","body":"<p>I need to start a telephone call and I am using this code (that works perfectly):</p>\n\n<pre><code>NSString *phoneCallNum = [NSString stringWithFormat:@\"tel://%@\",phoneNumber];\n\n[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneCallNum]];\n</code></pre>\n\n<p>But I need to check if the call was connected or simply the call ended without connect.</p>\n\n<p>I found that Core Telephony notifies this using something like:</p>\n\n<pre><code>[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callConnected:) name:CTCallStateConnected\n object:[UIApplication sharedApplication]];\n\n[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callEnded:) name:CTCallStateDisconnected object:[UIApplication sharedApplication]];\n</code></pre>\n\n<p>So how can I link both? I tried this code:</p>\n\n<pre><code>- (void)callNumber:(CDVInvokedUrlCommand*)command\n{\n CDVPluginResult* pluginResult = nil;\n NSString* phoneNumber = [command.arguments objectAtIndex:0];\n\n self.callbackID = command.callbackId;\n\n [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callConnected:) name:CTCallStateConnected\n object:[UIApplication sharedApplication]];\n\n [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callEnded:) name:CTCallStateDisconnected object:[UIApplication sharedApplication]];\n\n NSString *phoneCallNum = [NSString stringWithFormat:@\"tel://%@\",phoneNumber];\n\n [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneCallNum]];\n\n NSLog(@\"phone btn touch %@\", phoneCallNum);\n}\n\n- (void) callConnected: (NSNotification *)notification\n{\n BOOL succeeded = YES;\n NSLog(@\"Call connected\");\n}\n</code></pre>\n\n<p>Thanks in advance,</p>\n\n<p>Rodrigo.</p>\n"},{"tags":["java","postgresql","maven","jooq"],"owner":{"reputation":103,"user_id":669378,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/321895588335717d7855b0e70c64b646?s=128&d=identicon&r=PG","display_name":"csgeek","link":"http://stackoverflow.com/users/669378/csgeek"},"comment_count":0,"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1414773414,"creation_date":1414773414,"question_id":26679415,"body_markdown":"I'm trying to use maven to auto generate pojo for my postgres database. Though even if I take maven out of the equation I have the issue.\r\n\r\nMy data is split upon multiple schemas, and I'll need to work with all of them in my code base. I'd like to know how I can accomplish this short of setting up a task for each one of them in maven. This is what I have so far.\r\n\r\nObviously this only seems to work for a single schema. I'd like to be able to generate POJOs for multiple ones. I tried multiple xml elements, or comma delimited but it just errors out.\r\n\r\n```\r\n mvn -PDBGen generate-sources #is the command i use\r\n ```\r\n\r\n <?xml version="1.0" encoding="UTF-8"?>\r\n <project xmlns="http://maven.apache.org/POM/4.0.0"\r\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r\n xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r\n <modelVersion>4.0.0</modelVersion>\r\n \r\n <groupId>com.foobar.sandbox</groupId>\r\n <artifactId>playBox</artifactId>\r\n <version>1.0-SNAPSHOT</version>\r\n <packaging>war</packaging>\r\n \r\n <properties>\r\n <jooq-version>3.4.4</jooq-version>\r\n <psql-version>9.1-901-1.jdbc4</psql-version>\r\n </properties>\r\n \r\n <profiles>\r\n <profile>\r\n <id>DBGen</id>\r\n \r\n <build>\r\n <plugins>\r\n \r\n <!-- Maven Auto Generation -->\r\n <plugin>\r\n <groupId>org.jooq</groupId>\r\n <artifactId>jooq-codegen-maven</artifactId>\r\n <version>${jooq-version}</version>\r\n \r\n <!-- The plugin should hook into the generate goal -->\r\n <executions>\r\n <execution>\r\n <goals>\r\n <goal>generate</goal>\r\n </goals>\r\n </execution>\r\n </executions>\r\n \r\n <!-- Manage the plugin's dependency. In this example, we'll use a PostgreSQL database -->\r\n <dependencies>\r\n <dependency>\r\n <groupId>postgresql</groupId>\r\n <artifactId>postgresql</artifactId>\r\n <version>${psql-version}</version>\r\n </dependency>\r\n </dependencies>\r\n \r\n <!-- Specify the plugin configuration.\r\n The configuration format is the same as for the standalone code generator -->\r\n <configuration>\r\n \r\n <!-- JDBC connection parameters -->\r\n <jdbc>\r\n <driver>org.postgresql.Driver</driver>\r\n <url>jdbc:postgresql://localhost:5433/mydb</url>\r\n <user>user</user>\r\n <password>s3cret</password>\r\n </jdbc>\r\n \r\n <!-- Generator parameters -->\r\n <generator>\r\n <name>org.jooq.util.DefaultGenerator</name>\r\n <database>\r\n <name>org.jooq.util.postgres.PostgresDatabase</name>\r\n <includes>.*</includes>\r\n <inputSchema>ui</inputSchema>\r\n <excludes></excludes>\r\n </database>\r\n <target>\r\n <packageName>com.foobar.playbox.jooq.generated</packageName>\r\n <directory>target/generated-sources/jooq</directory>\r\n </target>\r\n </generator>\r\n </configuration>\r\n </plugin>\r\n </plugins>\r\n </build>\r\n </profile>\r\n \r\n </profiles>\r\n \r\n \r\n <build>\r\n <plugins>\r\n <!-- compiler -->\r\n <plugin>\r\n <artifactId>maven-compiler-plugin</artifactId>\r\n <version>3.1</version>\r\n <configuration>\r\n <source>1.7</source>\r\n <target>1.7</target>\r\n </configuration>\r\n </plugin>\r\n <plugin>\r\n <groupId>org.codehaus.mojo</groupId>\r\n <artifactId>build-helper-maven-plugin</artifactId>\r\n <executions>\r\n <execution>\r\n <phase>generate-sources</phase>\r\n <goals>\r\n <goal>add-source</goal>\r\n </goals>\r\n <configuration>\r\n <sources>\r\n <source>target/generated-sources/jooq</source>\r\n </sources>\r\n </configuration>\r\n </execution>\r\n </executions>\r\n </plugin>\r\n \r\n </plugins>\r\n </build>\r\n \r\n \r\n <dependencies>\r\n <!-- postgres -->\r\n <dependency>\r\n <groupId>postgresql</groupId>\r\n <artifactId>postgresql</artifactId>\r\n <version>${psql-version}</version>\r\n </dependency>\r\n <!-- mysql -->\r\n <dependency>\r\n <groupId>mysql</groupId>\r\n <artifactId>mysql-connector-java</artifactId>\r\n <version>5.1.33</version>\r\n </dependency>\r\n <!-- DataBase -->\r\n <dependency>\r\n <groupId>org.jooq</groupId>\r\n <artifactId>jooq</artifactId>\r\n <version>${jooq-version}</version>\r\n </dependency>\r\n <dependency>\r\n <groupId>org.jooq</groupId>\r\n <artifactId>jooq-meta</artifactId>\r\n <version>${jooq-version}</version>\r\n </dependency>\r\n <dependency>\r\n <groupId>org.jooq</groupId>\r\n <artifactId>jooq-codegen</artifactId>\r\n <version>${jooq-version}</version>\r\n </dependency>\r\n <!-- Logging -->\r\n <dependency>\r\n <groupId>org.slf4j</groupId>\r\n <artifactId>slf4j-api</artifactId>\r\n <version>1.7.7</version>\r\n </dependency>\r\n <dependency>\r\n <groupId>org.slf4j</groupId>\r\n <artifactId>slf4j-log4j12</artifactId>\r\n <version>1.7.7</version>\r\n </dependency>\r\n <dependency>\r\n <groupId>log4j</groupId>\r\n <artifactId>log4j</artifactId>\r\n <version>1.2.16</version>\r\n </dependency>\r\n <!-- Test -->\r\n <dependency>\r\n <groupId>org.mockito</groupId>\r\n <artifactId>mockito-all</artifactId>\r\n <version>1.9.5</version>\r\n <scope>test</scope>\r\n </dependency>\r\n </dependencies>\r\n \r\n </project>","link":"http://stackoverflow.com/questions/26679415/jooq-maven-and-multiple-schemas","title":"Jooq Maven and multiple schemas","body":"<p>I'm trying to use maven to auto generate pojo for my postgres database. Though even if I take maven out of the equation I have the issue.</p>\n\n<p>My data is split upon multiple schemas, and I'll need to work with all of them in my code base. I'd like to know how I can accomplish this short of setting up a task for each one of them in maven. This is what I have so far.</p>\n\n<p>Obviously this only seems to work for a single schema. I'd like to be able to generate POJOs for multiple ones. I tried multiple xml elements, or comma delimited but it just errors out.</p>\n\n<p><code>\n mvn -PDBGen generate-sources #is the command i use\n</code></p>\n\n<pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n <modelVersion>4.0.0</modelVersion>\n\n <groupId>com.foobar.sandbox</groupId>\n <artifactId>playBox</artifactId>\n <version>1.0-SNAPSHOT</version>\n <packaging>war</packaging>\n\n <properties>\n <jooq-version>3.4.4</jooq-version>\n <psql-version>9.1-901-1.jdbc4</psql-version>\n </properties>\n\n <profiles>\n <profile>\n <id>DBGen</id>\n\n <build>\n <plugins>\n\n <!-- Maven Auto Generation -->\n <plugin>\n <groupId>org.jooq</groupId>\n <artifactId>jooq-codegen-maven</artifactId>\n <version>${jooq-version}</version>\n\n <!-- The plugin should hook into the generate goal -->\n <executions>\n <execution>\n <goals>\n <goal>generate</goal>\n </goals>\n </execution>\n </executions>\n\n <!-- Manage the plugin's dependency. In this example, we'll use a PostgreSQL database -->\n <dependencies>\n <dependency>\n <groupId>postgresql</groupId>\n <artifactId>postgresql</artifactId>\n <version>${psql-version}</version>\n </dependency>\n </dependencies>\n\n <!-- Specify the plugin configuration.\n The configuration format is the same as for the standalone code generator -->\n <configuration>\n\n <!-- JDBC connection parameters -->\n <jdbc>\n <driver>org.postgresql.Driver</driver>\n <url>jdbc:postgresql://localhost:5433/mydb</url>\n <user>user</user>\n <password>s3cret</password>\n </jdbc>\n\n <!-- Generator parameters -->\n <generator>\n <name>org.jooq.util.DefaultGenerator</name>\n <database>\n <name>org.jooq.util.postgres.PostgresDatabase</name>\n <includes>.*</includes>\n <inputSchema>ui</inputSchema>\n <excludes></excludes>\n </database>\n <target>\n <packageName>com.foobar.playbox.jooq.generated</packageName>\n <directory>target/generated-sources/jooq</directory>\n </target>\n </generator>\n </configuration>\n </plugin>\n </plugins>\n </build>\n </profile>\n\n </profiles>\n\n\n <build>\n <plugins>\n <!-- compiler -->\n <plugin>\n <artifactId>maven-compiler-plugin</artifactId>\n <version>3.1</version>\n <configuration>\n <source>1.7</source>\n <target>1.7</target>\n </configuration>\n </plugin>\n <plugin>\n <groupId>org.codehaus.mojo</groupId>\n <artifactId>build-helper-maven-plugin</artifactId>\n <executions>\n <execution>\n <phase>generate-sources</phase>\n <goals>\n <goal>add-source</goal>\n </goals>\n <configuration>\n <sources>\n <source>target/generated-sources/jooq</source>\n </sources>\n </configuration>\n </execution>\n </executions>\n </plugin>\n\n </plugins>\n </build>\n\n\n <dependencies>\n <!-- postgres -->\n <dependency>\n <groupId>postgresql</groupId>\n <artifactId>postgresql</artifactId>\n <version>${psql-version}</version>\n </dependency>\n <!-- mysql -->\n <dependency>\n <groupId>mysql</groupId>\n <artifactId>mysql-connector-java</artifactId>\n <version>5.1.33</version>\n </dependency>\n <!-- DataBase -->\n <dependency>\n <groupId>org.jooq</groupId>\n <artifactId>jooq</artifactId>\n <version>${jooq-version}</version>\n </dependency>\n <dependency>\n <groupId>org.jooq</groupId>\n <artifactId>jooq-meta</artifactId>\n <version>${jooq-version}</version>\n </dependency>\n <dependency>\n <groupId>org.jooq</groupId>\n <artifactId>jooq-codegen</artifactId>\n <version>${jooq-version}</version>\n </dependency>\n <!-- Logging -->\n <dependency>\n <groupId>org.slf4j</groupId>\n <artifactId>slf4j-api</artifactId>\n <version>1.7.7</version>\n </dependency>\n <dependency>\n <groupId>org.slf4j</groupId>\n <artifactId>slf4j-log4j12</artifactId>\n <version>1.7.7</version>\n </dependency>\n <dependency>\n <groupId>log4j</groupId>\n <artifactId>log4j</artifactId>\n <version>1.2.16</version>\n </dependency>\n <!-- Test -->\n <dependency>\n <groupId>org.mockito</groupId>\n <artifactId>mockito-all</artifactId>\n <version>1.9.5</version>\n <scope>test</scope>\n </dependency>\n </dependencies>\n\n</project>\n</code></pre>\n"},{"tags":["sharepoint","sharepoint-2010","sharepoint-2013","event-receiver","sharepoint-feature"],"owner":{"reputation":1390,"user_id":34683,"user_type":"registered","accept_rate":91,"profile_image":"https://www.gravatar.com/avatar/28ebb0bf4b489823ac766ad87c87ba9b?s=128&d=identicon&r=PG","display_name":"GR7","link":"http://stackoverflow.com/users/34683/gr7"},"comment_count":0,"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1414773410,"creation_date":1414773410,"question_id":26679412,"body_markdown":"I'm very new to SharePoint development, and I'm just trying to add an XML file to a Feature to reference the XML file content in the feature Event Receiver.\r\n\r\nIt seems that the general recommendation is to use do so like in this SO question:\r\n\r\nhttp://stackoverflow.com/questions/5571028/how-to-retreive-data-from-an-xml-file-in-a-sharepoint-2010-feature-event-recieve\r\n\r\nHowever, my code does not compile when I reference the RootDirectory property. The error I see is below\r\n\r\n'Microsoft.SharePoint.Administration.SPFeatureDefinition' does not contain a definition for 'RootDirectory' and no extension method 'RootDirectory' accepting a first argument of type 'Microsoft.SharePoint.Administration.SPFeatureDefinition' could be found (are you missing a using directive or an assembly reference?\r\n\r\nNow, the weird part is that while debugging, I am able to evaluate the RootDirectory property correctly in the Quick Debug window.\r\n\r\nAm I missing something obvious? Like I said, I'm completely new to SharePoint.\r\n\r\nMy feature is scoped to the Web level, and I do have a reference to Microsoft.Sharepoint.Administration in my using statements.\r\n\r\nAny help is greatly appreciated, thanks.","link":"http://stackoverflow.com/questions/26679412/how-to-fix-spfeaturedefinition-does-not-contain-a-definition-for-rootdirectory","title":"How to fix SPFeatureDefinition does not contain a definition for RootDirectory","body":"<p>I'm very new to SharePoint development, and I'm just trying to add an XML file to a Feature to reference the XML file content in the feature Event Receiver.</p>\n\n<p>It seems that the general recommendation is to use do so like in this SO question:</p>\n\n<p><a href=\"http://stackoverflow.com/questions/5571028/how-to-retreive-data-from-an-xml-file-in-a-sharepoint-2010-feature-event-recieve\">How to retreive data from an XML file in a sharepoint 2010 Feature Event Reciever?</a></p>\n\n<p>However, my code does not compile when I reference the RootDirectory property. The error I see is below</p>\n\n<p>'Microsoft.SharePoint.Administration.SPFeatureDefinition' does not contain a definition for 'RootDirectory' and no extension method 'RootDirectory' accepting a first argument of type 'Microsoft.SharePoint.Administration.SPFeatureDefinition' could be found (are you missing a using directive or an assembly reference?</p>\n\n<p>Now, the weird part is that while debugging, I am able to evaluate the RootDirectory property correctly in the Quick Debug window.</p>\n\n<p>Am I missing something obvious? Like I said, I'm completely new to SharePoint.</p>\n\n<p>My feature is scoped to the Web level, and I do have a reference to Microsoft.Sharepoint.Administration in my using statements.</p>\n\n<p>Any help is greatly appreciated, thanks.</p>\n"},{"answers":[{"owner":{"reputation":203,"user_id":579343,"user_type":"registered","accept_rate":71,"profile_image":"https://www.gravatar.com/avatar/896cde12ae62bb66f06773cd53f15233?s=128&d=identicon&r=PG","display_name":"cksum","link":"http://stackoverflow.com/users/579343/cksum"},"comment_count":0,"is_accepted":false,"score":1,"last_activity_date":1295335187,"creation_date":1295335187,"answer_id":4721427,"question_id":4721396,"body_markdown":"No. Serial numbers are optional on USB drives. Some manufacturers use them, others do not.","link":"http://stackoverflow.com/questions/4721396/every-usb-flash-drives-manufactured-by-any-company-have-unique-serial-key-or-not/4721427#4721427","body":"<p>No. Serial numbers are optional on USB drives. Some manufacturers use them, others do not.</p>\n"}],"tags":["usb","key","serial-number","usb-flash-drive"],"owner":{"reputation":6,"user_id":579533,"user_type":"unregistered","profile_image":"https://www.gravatar.com/avatar/daca322d8b0fa69c61a5661340d67029?s=128&d=identicon&r=PG","display_name":"prajjwal shakya","link":"http://stackoverflow.com/users/579533/prajjwal-shakya"},"comment_count":0,"is_answered":true,"view_count":422,"answer_count":1,"score":1,"last_activity_date":1414773410,"creation_date":1295334926,"last_edit_date":1414773410,"question_id":4721396,"body_markdown":"I would like to know, if every usb flash drives manufactured by any company have unique serial key or not? If yes, can we retrieve it using any programming languages.","link":"http://stackoverflow.com/questions/4721396/every-usb-flash-drives-manufactured-by-any-company-have-unique-serial-key-or-not","title":"every usb flash drives manufactured by any company have unique serial key or not?","body":"<p>I would like to know, if every usb flash drives manufactured by any company have unique serial key or not? If yes, can we retrieve it using any programming languages.</p>\n"},{"answers":[{"owner":{"reputation":26812,"user_id":717214,"user_type":"registered","accept_rate":92,"profile_image":"https://www.gravatar.com/avatar/9075315c5f4b734a8f2567be54a4cc45?s=128&d=identicon&r=PG","display_name":"Aleks G","link":"http://stackoverflow.com/users/717214/aleks-g"},"comment_count":0,"is_accepted":false,"score":1,"last_activity_date":1414773311,"creation_date":1414773311,"answer_id":26679386,"question_id":26679341,"body_markdown":"Just url-decode the value before returning. Replace\r\n\r\n return sParameterName[1];\r\n\r\nwith \r\n\r\n return decodeURIComponent(sParameterName[1]);","link":"http://stackoverflow.com/questions/26679341/function-geturlparametersparam-is-returning-20-as-white-space-on-page/26679386#26679386","body":"<p>Just url-decode the value before returning. Replace</p>\n\n<pre><code>return sParameterName[1];\n</code></pre>\n\n<p>with </p>\n\n<pre><code>return decodeURIComponent(sParameterName[1]);\n</code></pre>\n"},{"owner":{"reputation":386,"user_id":3509191,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/20154f137f9370563e03d9ca04d4552d?s=128&d=identicon&r=PG","display_name":"JonathanAMcCann","link":"http://stackoverflow.com/users/3509191/jonathanamccann"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773410,"creation_date":1414773410,"answer_id":26679413,"question_id":26679341,"body_markdown":"The text you are seeing is what's called `url-encoded`. You simply need to decode it before displaying it:\r\n\r\n function GetURLParameter(sParam)\r\n { \r\n var sPageURL = window.location.search.substring(1);\r\n var sURLVariables = sPageURL.split('&');\r\n for (var i = 0; i < sURLVariables.length; i++) \r\n {\r\n var sParameterName = sURLVariables[i].split('=');\r\n if (sParameterName[0] == sParam) \r\n {\r\n return return decodeURIComponent(sParameterName[1]);\r\n }\r\n }\r\n }","link":"http://stackoverflow.com/questions/26679341/function-geturlparametersparam-is-returning-20-as-white-space-on-page/26679413#26679413","body":"<p>The text you are seeing is what's called <code>url-encoded</code>. You simply need to decode it before displaying it:</p>\n\n<pre><code>function GetURLParameter(sParam)\n { \n var sPageURL = window.location.search.substring(1);\n var sURLVariables = sPageURL.split('&');\n for (var i = 0; i < sURLVariables.length; i++) \n {\n var sParameterName = sURLVariables[i].split('=');\n if (sParameterName[0] == sParam) \n {\n return return decodeURIComponent(sParameterName[1]);\n }\n }\n}\n</code></pre>\n"}],"tags":["javascript","jquery"],"owner":{"reputation":1,"user_id":4203170,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/61cdd93e5c204e75065074a99cda76ec?s=128&d=identicon&r=PG&f=1","display_name":"drm930","link":"http://stackoverflow.com/users/4203170/drm930"},"comment_count":0,"is_answered":true,"view_count":18,"answer_count":2,"score":0,"last_activity_date":1414773410,"creation_date":1414773150,"last_edit_date":1414773238,"question_id":26679341,"body_markdown":"I have this code that pulls the URL parameter into the landing page, the issue is it is pulling white space in as %20. So if my url parameter is:\r\nexample.com/?title=my website it wil display my%20website on the page i want it to display my website without the %20. Here is the code\r\n\r\n\r\n function GetURLParameter(sParam)\r\n { \r\n var sPageURL = window.location.search.substring(1);\r\n var sURLVariables = sPageURL.split('&');\r\n for (var i = 0; i < sURLVariables.length; i++) \r\n {\r\n var sParameterName = sURLVariables[i].split('=');\r\n if (sParameterName[0] == sParam) \r\n {\r\n return sParameterName[1];\r\n }\r\n }\r\n }\r\n\r\n (function ($) {\r\n // fire once DOM is loaded\r\n $(document).ready(function() {\r\n // set the cookie name\r\n var cookie_name = 'node-title';\r\n // get the "phone" URL param\r\n var phone_number = GetURLParameter('title');\r\n // check if there is a phone number in the URL\r\n if (phone_number) {\r\n // set the cookie\r\n $.cookie(cookie_name, phone_number, { path: '/' });\r\n }\r\n // get the phone cookie value\r\n var phone_cookie = $.cookie(cookie_name);\r\n // check if there is a value set in the phone cookie\r\n if (phone_cookie) {\r\n // swap the phone number\r\n $('.' + cookie_name).html(phone_cookie);\r\n // update the href too\r\n $('a.' + cookie_name).attr('href', 'tel://' + phone_cookie);\r\n }\r\n });\r\n })(jQuery);\r\n\r\n","link":"http://stackoverflow.com/questions/26679341/function-geturlparametersparam-is-returning-20-as-white-space-on-page","title":"function GetURLParameter(sParam) is returning %20 as white space on page","body":"<p>I have this code that pulls the URL parameter into the landing page, the issue is it is pulling white space in as %20. So if my url parameter is:\nexample.com/?title=my website it wil display my%20website on the page i want it to display my website without the %20. Here is the code</p>\n\n<pre><code>function GetURLParameter(sParam)\n { \n var sPageURL = window.location.search.substring(1);\n var sURLVariables = sPageURL.split('&');\n for (var i = 0; i < sURLVariables.length; i++) \n {\n var sParameterName = sURLVariables[i].split('=');\n if (sParameterName[0] == sParam) \n {\n return sParameterName[1];\n }\n }\n }\n\n(function ($) {\n// fire once DOM is loaded\n$(document).ready(function() {\n // set the cookie name\n var cookie_name = 'node-title';\n // get the \"phone\" URL param\n var phone_number = GetURLParameter('title');\n // check if there is a phone number in the URL\n if (phone_number) {\n // set the cookie\n $.cookie(cookie_name, phone_number, { path: '/' });\n }\n // get the phone cookie value\n var phone_cookie = $.cookie(cookie_name);\n // check if there is a value set in the phone cookie\n if (phone_cookie) {\n // swap the phone number\n $('.' + cookie_name).html(phone_cookie);\n // update the href too\n $('a.' + cookie_name).attr('href', 'tel://' + phone_cookie);\n }\n });\n })(jQuery);\n</code></pre>\n"},{"answers":[{"owner":{"reputation":2468,"user_id":2679518,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/edd2a1f8eda8121add9c4fc9d4d544e0?s=128&d=identicon&r=PG&f=1","display_name":"John Paul","link":"http://stackoverflow.com/users/2679518/john-paul"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773320,"creation_date":1414773320,"answer_id":26679391,"question_id":26678702,"body_markdown":"You need to pass a list of limits to the `xyplot`. Here I did that outside of the `xyplot` but you could do that right in the `scales` argument if you wish.\r\n\r\n library(lattice)\r\n size <- rep(c("da","db","ca","cb"),each=5) \r\n age <- rep(1:5,4)\r\n growth <- rep(c(-75,-55,-25,-20),each=5)\r\n test <- data.frame(size,age,growth)\r\n\r\n YLims<-list(c(-20,30),c(-20,30),c(-50,-80),c(-50,-80) )\r\n\r\n xyplot(growth~age|factor(size),\r\n layout=c(2,2), \r\n type=c("p","g"), \r\n scales=list(x=list(tick.number=3), y=list(relation="free", limits=YLims)), \r\n ylab="growth %",xlab="age",pch=20,col="black", data=test)\r\n\r\n![enter image description here][1]\r\n\r\n\r\n [1]: http://i.stack.imgur.com/ywhc2.jpg","link":"http://stackoverflow.com/questions/26678702/lattice-separate-y-axes-for-row-of-xyplot/26679391#26679391","body":"<p>You need to pass a list of limits to the <code>xyplot</code>. Here I did that outside of the <code>xyplot</code> but you could do that right in the <code>scales</code> argument if you wish.</p>\n\n<pre><code>library(lattice)\nsize <- rep(c(\"da\",\"db\",\"ca\",\"cb\"),each=5) \nage <- rep(1:5,4)\ngrowth <- rep(c(-75,-55,-25,-20),each=5)\ntest <- data.frame(size,age,growth)\n\nYLims<-list(c(-20,30),c(-20,30),c(-50,-80),c(-50,-80) )\n\nxyplot(growth~age|factor(size),\n layout=c(2,2), \n type=c(\"p\",\"g\"), \n scales=list(x=list(tick.number=3), y=list(relation=\"free\", limits=YLims)), \n ylab=\"growth %\",xlab=\"age\",pch=20,col=\"black\", data=test)\n</code></pre>\n\n<p><img src=\"http://i.stack.imgur.com/ywhc2.jpg\" alt=\"enter image description here\"></p>\n"}],"tags":["r","lattice"],"owner":{"reputation":16,"user_id":1632334,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ca33bb312b676687386535c8cac0e77d?s=128&d=identicon&r=PG","display_name":"ma-d","link":"http://stackoverflow.com/users/1632334/ma-d"},"comment_count":0,"is_answered":false,"view_count":7,"answer_count":1,"score":0,"last_activity_date":1414773409,"creation_date":1414770944,"last_edit_date":1414773409,"question_id":26678702,"body_markdown":"I wish to have the same y-axis limits for a row of an `xyplot` with a 2 by 2 display. Neither `scales = "free"`, nor `scales = "sliced"` will achieve this. \r\n\r\n### toy example\r\n\r\n size <- rep(c("da","db","ca","cb"),each=5) \r\n age <- rep(1:5,4) \r\n growth <- rep(c(-75,-55,-25,-20),each=5) \r\n\r\n test <- data.frame(size,age,growth)\r\n\r\n\r\n xyplot(growth~age|factor(size),layout=c(2,2),\r\n type=c("p","g"),\r\n scales=list(x=list(tick.number=3)),\r\n ylab="growth %",xlab="age",pch=20,col="black",\r\n data=test)\r\n\r\nin this case I would like to have (in base graphics): `ylim=c(-50,-80)` for the first row and `y=c(-20,-30)` for the second row.","link":"http://stackoverflow.com/questions/26678702/lattice-separate-y-axes-for-row-of-xyplot","title":"lattice separate y axes for row of xyplot","body":"<p>I wish to have the same y-axis limits for a row of an <code>xyplot</code> with a 2 by 2 display. Neither <code>scales = \"free\"</code>, nor <code>scales = \"sliced\"</code> will achieve this. </p>\n\n<h3>toy example</h3>\n\n<pre><code>size <- rep(c(\"da\",\"db\",\"ca\",\"cb\"),each=5) \nage <- rep(1:5,4) \ngrowth <- rep(c(-75,-55,-25,-20),each=5) \n\ntest <- data.frame(size,age,growth)\n\n\nxyplot(growth~age|factor(size),layout=c(2,2),\n type=c(\"p\",\"g\"),\n scales=list(x=list(tick.number=3)),\n ylab=\"growth %\",xlab=\"age\",pch=20,col=\"black\",\n data=test)\n</code></pre>\n\n<p>in this case I would like to have (in base graphics): <code>ylim=c(-50,-80)</code> for the first row and <code>y=c(-20,-30)</code> for the second row.</p>\n"},{"answers":[{"owner":{"reputation":23767,"user_id":1415724,"user_type":"registered","accept_rate":82,"profile_image":"http://i.stack.imgur.com/uBEOB.jpg?s=128&g=1","display_name":"Fred -ii-","link":"http://stackoverflow.com/users/1415724/fred-ii"},"comments":[{"owner":{"reputation":7086,"user_id":999553,"user_type":"registered","accept_rate":95,"profile_image":"https://www.gravatar.com/avatar/b7519342f152f031523782cf1ee44f09?s=128&d=identicon&r=PG","display_name":"Set Sail Media","link":"http://stackoverflow.com/users/999553/set-sail-media"},"edited":false,"score":1,"creation_date":1414772061,"post_id":26679013,"comment_id":41957032},{"owner":{"reputation":23767,"user_id":1415724,"user_type":"registered","accept_rate":82,"profile_image":"http://i.stack.imgur.com/uBEOB.jpg?s=128&g=1","display_name":"Fred -ii-","link":"http://stackoverflow.com/users/1415724/fred-ii"},"reply_to_user":{"reputation":7086,"user_id":999553,"user_type":"registered","accept_rate":95,"profile_image":"https://www.gravatar.com/avatar/b7519342f152f031523782cf1ee44f09?s=128&d=identicon&r=PG","display_name":"Set Sail Media","link":"http://stackoverflow.com/users/999553/set-sail-media"},"edited":false,"score":0,"creation_date":1414772094,"post_id":26679013,"comment_id":41957046}],"last_editor":{"reputation":23767,"user_id":1415724,"user_type":"registered","accept_rate":82,"profile_image":"http://i.stack.imgur.com/uBEOB.jpg?s=128&g=1","display_name":"Fred -ii-","link":"http://stackoverflow.com/users/1415724/fred-ii"},"comment_count":2,"is_accepted":false,"score":0,"last_activity_date":1414772676,"last_edit_date":1414772676,"creation_date":1414772045,"answer_id":26679013,"question_id":26678972,"body_markdown":"Change `$body, "From:" . $headers)` to `$body, $headers)` \r\n\r\nYou already have the `From:` in:\r\n\r\n $headers = "From: Staff <contacto@evento.com>"...\r\n\r\nPlus as noted in comments, change and remove the `"To:" .`\r\n\r\n mail( "To:" . $memberemail , "Nuevo registro", $body, "From:" . $headers);\r\n\r\nto\r\n\r\n mail($memberemail, "Nuevo registro", $body, $headers);\r\n\r\n\r\n\r\nMail automatically sets the first parameter as the recipient `To:`\r\n\r\nHowever, you may have wanted to use `$youremail` as the first parameter and `$memberemail` as the `From:`, because mail will be sent to the person who sent the Email, but I will let you decide on that.\r\n\r\nConsult the manual:\r\n\r\n - **http://php.net/manual/en/function.mail.php**\r\n\r\n","link":"http://stackoverflow.com/questions/26678972/sender-mail-with-php/26679013#26679013","body":"<p>Change <code>$body, \"From:\" . $headers)</code> to <code>$body, $headers)</code> </p>\n\n<p>You already have the <code>From:</code> in:</p>\n\n<pre><code>$headers = \"From: Staff <contacto@evento.com>\"...\n</code></pre>\n\n<p>Plus as noted in comments, change and remove the <code>\"To:\" .</code></p>\n\n<pre><code>mail( \"To:\" . $memberemail , \"Nuevo registro\", $body, \"From:\" . $headers);\n</code></pre>\n\n<p>to</p>\n\n<pre><code>mail($memberemail, \"Nuevo registro\", $body, $headers);\n</code></pre>\n\n<p>Mail automatically sets the first parameter as the recipient <code>To:</code></p>\n\n<p>However, you may have wanted to use <code>$youremail</code> as the first parameter and <code>$memberemail</code> as the <code>From:</code>, because mail will be sent to the person who sent the Email, but I will let you decide on that.</p>\n\n<p>Consult the manual:</p>\n\n<ul>\n<li><strong><a href=\"http://php.net/manual/en/function.mail.php\" rel=\"nofollow\">http://php.net/manual/en/function.mail.php</a></strong></li>\n</ul>\n"},{"owner":{"reputation":785,"user_id":467367,"user_type":"registered","accept_rate":60,"profile_image":"https://www.gravatar.com/avatar/b04e055a9c45fe9bdbee2ebe4c2d4957?s=128&d=identicon&r=PG","display_name":"Alexey","link":"http://stackoverflow.com/users/467367/alexey"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414772154,"creation_date":1414772154,"answer_id":26679051,"question_id":26678972,"body_markdown":"I think it has to do with the following:\r\n\r\n1. Set SPF record on evento.com domain to allow this ip or subnet to use this From address. You can use a tool like this: http://www.spfwizard.net/\r\n2. Add PTR record on event.com domain pointing to the IP of the sending host\r\n3. Remove the whole body and try to add line-by-line (making sure content-based spam filters are not in effect)\r\n4. Watch your mail log and see whether it's sent out by MTA and your smarthost response code. \r\n\r\nAnd you should specify what exactly you mean by "stopped working": was it sent out from the server? Did it land into junk box? Was it rejected by your smarthost?\r\n\r\n","link":"http://stackoverflow.com/questions/26678972/sender-mail-with-php/26679051#26679051","body":"<p>I think it has to do with the following:</p>\n\n<ol>\n<li>Set SPF record on evento.com domain to allow this ip or subnet to use this From address. You can use a tool like this: <a href=\"http://www.spfwizard.net/\" rel=\"nofollow\">http://www.spfwizard.net/</a></li>\n<li>Add PTR record on event.com domain pointing to the IP of the sending host</li>\n<li>Remove the whole body and try to add line-by-line (making sure content-based spam filters are not in effect)</li>\n<li>Watch your mail log and see whether it's sent out by MTA and your smarthost response code. </li>\n</ol>\n\n<p>And you should specify what exactly you mean by \"stopped working\": was it sent out from the server? Did it land into junk box? Was it rejected by your smarthost?</p>\n"}],"tags":["php","email"],"owner":{"reputation":10,"user_id":3588175,"user_type":"registered","accept_rate":50,"profile_image":"http://i.stack.imgur.com/uQelN.jpg?s=128&g=1","display_name":"hmaceves","link":"http://stackoverflow.com/users/3588175/hmaceves"},"comments":[{"owner":{"reputation":456,"user_id":2923632,"user_type":"registered","profile_image":"http://graph.facebook.com/1672665750/picture?type=large","display_name":"Joseph Neathawk","link":"http://stackoverflow.com/users/2923632/joseph-neathawk"},"edited":false,"score":0,"creation_date":1414772024,"post_id":26678972,"comment_id":41957012},{"owner":{"reputation":54,"user_id":2737474,"user_type":"registered","profile_image":"http://graph.facebook.com/100000063508080/picture?type=large","display_name":"Charles Rojas","link":"http://stackoverflow.com/users/2737474/charles-rojas"},"edited":false,"score":1,"creation_date":1414772524,"post_id":26678972,"comment_id":41957259}],"comment_count":2,"is_answered":false,"view_count":25,"answer_count":2,"score":0,"last_activity_date":1414773409,"creation_date":1414771849,"last_edit_date":1414773409,"question_id":26678972,"body_markdown":"I use this code to send mail. But it stopped working when I added the **$headers** and lines to **$body**. Can anyone support me in finding the error or errors? \r\n\r\nI would appreciate the support.\r\n\r\n <?PHP\r\n\r\n // Email Address\r\n $youremail = 'correo@correo.com';\r\n\t$memberemail = $_POST['email'];\r\n\t\r\n // Register Form\r\n if ( isset($_POST['email']) && isset($_POST['name']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ) {\r\n\r\n // Detect & Prevent Header Injections\r\n $test = "/(content-type|bcc:|cc:|to:)/i";\r\n foreach ( $_POST as $key => $val ) {\r\n if ( preg_match( $test, $val ) ) {\r\n exit;\r\n }\r\n }\r\n\r\n // Email Format\r\n $body = "Hola! $_POST[name]. Gracias por solicitar tu inscripción. \\n";\r\n $body .= "Analizaremos tú solicitud y en caso de resultar positiva recibirás un correo de confirmación en las próximas 24 horas. \\n\\n";\r\n\t\t$body .=\t"Tus datos de solicitud son: \\r\\n"\r\n\t\t$body .=\t"============================ \\r\\n";\r\n $body .= "Nombre: $_POST[name] \\n";\r\n $body .= "eMail: $_POST[email] \\n";\r\n $body .= "Empresa: $_POST[telephone] \\n";\r\n $body .= "Sector: $_POST[ticket] \\n\\n";\r\n\t\t$body .= "Atentamente, \\n";\r\n\t\t$body .= "Staff \\n\\n";\r\n\t\t$body .= "NOTA: Para culaquier duda sobre tu proceso de inscripción te recomendamos leer las preguntas frecuentes en el sito web del evento http://www.evento.com";\r\n\t\t\r\n //Send email\r\n\t\r\n\t\t$headers = "From: Staff <contacto@evento.com>" . "\\r\\n" . "Bcc: admin@evento.com" . "\\r\\n";\r\n\t\t\r\n mail( "To:" . $memberemail , "Nuevo registro", $body, "From:" . $headers);\r\n\r\n }\r\n\r\n // Subscribe Form\r\n if( isset($_POST['subscriber']) && filter_var($_POST['subscriber'], FILTER_VALIDATE_EMAIL) ) {\r\n $data = $_POST['subscriber'] . ";" . "\\n";\r\n $ret = file_put_contents('subscribers.txt', $data, FILE_APPEND | LOCK_EX);\r\n if($ret === false) {\r\n die('Ouch! Al parecer hay un error.');\r\n }\r\n } else {\r\n die('No se pueden enviar los datos.');\r\n }\r\n\r\n ?>","link":"http://stackoverflow.com/questions/26678972/sender-mail-with-php","title":"sender mail with php","body":"<p>I use this code to send mail. But it stopped working when I added the <strong>$headers</strong> and lines to <strong>$body</strong>. Can anyone support me in finding the error or errors? </p>\n\n<p>I would appreciate the support.</p>\n\n<pre><code><?PHP\n\n// Email Address\n$youremail = 'correo@correo.com';\n$memberemail = $_POST['email'];\n\n// Register Form\nif ( isset($_POST['email']) && isset($_POST['name']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ) {\n\n // Detect & Prevent Header Injections\n $test = \"/(content-type|bcc:|cc:|to:)/i\";\n foreach ( $_POST as $key => $val ) {\n if ( preg_match( $test, $val ) ) {\n exit;\n }\n }\n\n // Email Format\n $body = \"Hola! $_POST[name]. Gracias por solicitar tu inscripción. \\n\";\n $body .= \"Analizaremos tú solicitud y en caso de resultar positiva recibirás un correo de confirmación en las próximas 24 horas. \\n\\n\";\n $body .= \"Tus datos de solicitud son: \\r\\n\"\n $body .= \"============================ \\r\\n\";\n $body .= \"Nombre: $_POST[name] \\n\";\n $body .= \"eMail: $_POST[email] \\n\";\n $body .= \"Empresa: $_POST[telephone] \\n\";\n $body .= \"Sector: $_POST[ticket] \\n\\n\";\n $body .= \"Atentamente, \\n\";\n $body .= \"Staff \\n\\n\";\n $body .= \"NOTA: Para culaquier duda sobre tu proceso de inscripción te recomendamos leer las preguntas frecuentes en el sito web del evento http://www.evento.com\";\n\n //Send email\n\n $headers = \"From: Staff <contacto@evento.com>\" . \"\\r\\n\" . \"Bcc: admin@evento.com\" . \"\\r\\n\";\n\n mail( \"To:\" . $memberemail , \"Nuevo registro\", $body, \"From:\" . $headers);\n\n}\n\n// Subscribe Form\nif( isset($_POST['subscriber']) && filter_var($_POST['subscriber'], FILTER_VALIDATE_EMAIL) ) {\n $data = $_POST['subscriber'] . \";\" . \"\\n\";\n $ret = file_put_contents('subscribers.txt', $data, FILE_APPEND | LOCK_EX);\n if($ret === false) {\n die('Ouch! Al parecer hay un error.');\n }\n} else {\n die('No se pueden enviar los datos.');\n}\n\n?>\n</code></pre>\n"},{"answers":[{"owner":{"reputation":15335,"user_id":3859027,"user_type":"registered","profile_image":"http://i.stack.imgur.com/EzRaV.jpg?s=128&g=1","display_name":"Ghost","link":"http://stackoverflow.com/users/3859027/ghost"},"comments":[{"owner":{"reputation":1857,"user_id":240385,"user_type":"registered","accept_rate":77,"profile_image":"http://i.stack.imgur.com/ZEcfq.jpg?s=128&g=1","display_name":"jason","link":"http://stackoverflow.com/users/240385/jason"},"edited":false,"score":0,"creation_date":1414772823,"post_id":26677790,"comment_id":41957411},{"owner":{"reputation":15335,"user_id":3859027,"user_type":"registered","profile_image":"http://i.stack.imgur.com/EzRaV.jpg?s=128&g=1","display_name":"Ghost","link":"http://stackoverflow.com/users/3859027/ghost"},"reply_to_user":{"reputation":1857,"user_id":240385,"user_type":"registered","accept_rate":77,"profile_image":"http://i.stack.imgur.com/ZEcfq.jpg?s=128&g=1","display_name":"jason","link":"http://stackoverflow.com/users/240385/jason"},"edited":false,"score":0,"creation_date":1414773341,"post_id":26677790,"comment_id":41957673}],"comment_count":2,"is_accepted":true,"score":1,"last_activity_date":1414768076,"creation_date":1414768076,"answer_id":26677790,"question_id":26677257,"body_markdown":"No, I wouldn't recommend regex, I strongly recommend build on what you have right now with the use of this beautiful HTML Parser. You could use `->replaceChild` in this case:\r\n\r\n $dom = new DOMDocument;\r\n $dom->loadHTML($getVal);\r\n $xPath = new DOMXPath($dom);\r\n \r\n $spans = $xPath->query('//span');\r\n foreach ($spans as $span) {\r\n \t$class = $xPath->evaluate('string(./@class)', $span);\r\n \tif(strpos($class, 'ice-ins') !== false || $class == '') {\r\n \t\t$span->parentNode->removeChild($span);\r\n \t} elseif(strpos($class, 'ice-del') !== false) {\r\n \t\t$span->parentNode->replaceChild(new DOMText($span->nodeValue), $span);\r\n \t}\r\n }\r\n \r\n $newString = $dom->saveHTML();","link":"http://stackoverflow.com/questions/26677257/php-using-domxpath-to-strip-tags-and-remove-nodes/26677790#26677790","body":"<p>No, I wouldn't recommend regex, I strongly recommend build on what you have right now with the use of this beautiful HTML Parser. You could use <code>->replaceChild</code> in this case:</p>\n\n<pre><code>$dom = new DOMDocument;\n$dom->loadHTML($getVal);\n$xPath = new DOMXPath($dom);\n\n$spans = $xPath->query('//span');\nforeach ($spans as $span) {\n $class = $xPath->evaluate('string(./@class)', $span);\n if(strpos($class, 'ice-ins') !== false || $class == '') {\n $span->parentNode->removeChild($span);\n } elseif(strpos($class, 'ice-del') !== false) {\n $span->parentNode->replaceChild(new DOMText($span->nodeValue), $span);\n }\n}\n\n$newString = $dom->saveHTML();\n</code></pre>\n"}],"tags":["php","html","xpath","domdocument"],"owner":{"reputation":1857,"user_id":240385,"user_type":"registered","accept_rate":77,"profile_image":"http://i.stack.imgur.com/ZEcfq.jpg?s=128&g=1","display_name":"jason","link":"http://stackoverflow.com/users/240385/jason"},"comment_count":0,"is_answered":true,"view_count":9,"accepted_answer_id":26677790,"answer_count":1,"score":1,"last_activity_date":1414773405,"creation_date":1414766368,"last_edit_date":1414773405,"question_id":26677257,"body_markdown":"I am trying to work with DOMDocument but I am encountering some problems. I have a string like this:\r\n\r\n Some Content to keep\r\n <span class="ice-cts-1 ice-del" data-changedata="" data-cid="5" data-time="1414514760583" data-userid="1" data-username="Site Administrator" undefined="Site Administrator">\r\n This content should remain, but span around it should be stripped\r\n </span> \r\n Keep this content too\r\n <span>\r\n <span class="ice-cts-1 ice-ins" data-changedata="" data-cid="2" data-time="1414512278297" data-userid="1" data-username="Site Administrator" undefined="Site Administrator">\r\n This whole node should be deleted\r\n </span>\r\n </span>\r\n\r\nWhat I want to do is, if the span has a class like `ice-del` keep the inner content but remove the span tags. If it has `ice-ins`, remove the whole node. \r\n\r\nIf it is just an empty span `<span></span>` remove it as well. This is the code I have:\r\n\r\n //this get the above mentioned string\r\n $getVal = $array['body'][0][$a];\r\n $dom = new DOMDocument;\r\n $dom->loadHTML($getVal );\r\n $xPath = new DOMXPath($dom);\r\n $delNodes = $xPath->query('//span[@class="ice-cts-1 ice-del"]');\r\n $insNodes = $xPath->query('//span[@class="ice-cts-1 ice-ins"]');\r\n \r\n foreach($insNodes as $span){\r\n //reject these changes, so remove whole node\r\n $span->parentNode->removeChild($span);\r\n }\r\n \r\n foreach($delNodes as $span){\r\n //accept these changes, so just strip out the tags but keep the content\r\n }\r\n \r\n $newString = $dom->saveHTML();\r\n\r\nSo, my code works to delete the entire span node, but how do I take a node and strip out it tags but keep its content? \r\n\r\nAlso, how would I just delete and empty span? I'm sure I could do this using regex or replace but I kind of want to do this using the dom.\r\n\r\nthanks","link":"http://stackoverflow.com/questions/26677257/php-using-domxpath-to-strip-tags-and-remove-nodes","title":"PHP Using DOMXPath to strip tags and remove nodes","body":"<p>I am trying to work with DOMDocument but I am encountering some problems. I have a string like this:</p>\n\n<pre><code>Some Content to keep\n<span class=\"ice-cts-1 ice-del\" data-changedata=\"\" data-cid=\"5\" data-time=\"1414514760583\" data-userid=\"1\" data-username=\"Site Administrator\" undefined=\"Site Administrator\">\n This content should remain, but span around it should be stripped\n</span> \n Keep this content too\n<span>\n <span class=\"ice-cts-1 ice-ins\" data-changedata=\"\" data-cid=\"2\" data-time=\"1414512278297\" data-userid=\"1\" data-username=\"Site Administrator\" undefined=\"Site Administrator\">\n This whole node should be deleted\n </span>\n</span>\n</code></pre>\n\n<p>What I want to do is, if the span has a class like <code>ice-del</code> keep the inner content but remove the span tags. If it has <code>ice-ins</code>, remove the whole node. </p>\n\n<p>If it is just an empty span <code><span></span></code> remove it as well. This is the code I have:</p>\n\n<pre><code>//this get the above mentioned string\n$getVal = $array['body'][0][$a];\n$dom = new DOMDocument;\n$dom->loadHTML($getVal );\n$xPath = new DOMXPath($dom);\n$delNodes = $xPath->query('//span[@class=\"ice-cts-1 ice-del\"]');\n$insNodes = $xPath->query('//span[@class=\"ice-cts-1 ice-ins\"]');\n\nforeach($insNodes as $span){\n //reject these changes, so remove whole node\n $span->parentNode->removeChild($span);\n}\n\nforeach($delNodes as $span){\n //accept these changes, so just strip out the tags but keep the content\n}\n\n$newString = $dom->saveHTML();\n</code></pre>\n\n<p>So, my code works to delete the entire span node, but how do I take a node and strip out it tags but keep its content? </p>\n\n<p>Also, how would I just delete and empty span? I'm sure I could do this using regex or replace but I kind of want to do this using the dom.</p>\n\n<p>thanks</p>\n"},{"tags":["java","eclipse","encryption"],"owner":{"reputation":3,"user_id":4156518,"user_type":"registered","profile_image":"http://graph.facebook.com/1388992019/picture?type=large","display_name":"Keegan Fargher","link":"http://stackoverflow.com/users/4156518/keegan-fargher"},"comment_count":0,"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1414773399,"creation_date":1414773399,"question_id":26679411,"body_markdown":"I started programming Java a few months ago, and I've recently been assigned to make my own encryption program. Obviously it's just for fun and it does not need to protect government secrets, but can someone give me some tips or ideas on how to go about making my own little encryption program? A bit advanced though. I don't want to just swap characters around using charAt or something... :P\r\n\r\nThanks in advance. :3","link":"http://stackoverflow.com/questions/26679411/encryption-program-homework","title":"Encryption Program (Homework)","body":"<p>I started programming Java a few months ago, and I've recently been assigned to make my own encryption program. Obviously it's just for fun and it does not need to protect government secrets, but can someone give me some tips or ideas on how to go about making my own little encryption program? A bit advanced though. I don't want to just swap characters around using charAt or something... :P</p>\n\n<p>Thanks in advance. :3</p>\n"},{"answers":[{"owner":{"reputation":266,"user_id":1239976,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/45dbb61d077deedaadf0a13e99d57ff7?s=128&d=identicon&r=PG","display_name":"quzary","link":"http://stackoverflow.com/users/1239976/quzary"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1330935589,"creation_date":1330935589,"answer_id":9563531,"question_id":9563479,"body_markdown":"try this:\r\n\r\n $(function(){\r\n var listCells = $.makeArray($("td"));\r\n $("td").click(function(){marked($(this),listCells)}); \r\n });\r\n \r\n \r\n \r\n function marked(o,arr)\r\n {\r\n ...","link":"http://stackoverflow.com/questions/9563479/how-to-pass-this-properly-in-click-jquery-function/9563531#9563531","body":"<p>try this:</p>\n\n<pre><code>$(function(){\n var listCells = $.makeArray($(\"td\"));\n $(\"td\").click(function(){marked($(this),listCells)}); \n});\n\n\n\nfunction marked(o,arr)\n{\n...\n</code></pre>\n"},{"owner":{"reputation":2676,"user_id":1045204,"user_type":"registered","accept_rate":40,"profile_image":"https://www.gravatar.com/avatar/f132c45bc2ea922d5a8a7e3818434e8a?s=128&d=identicon&r=PG","display_name":"Hadas","link":"http://stackoverflow.com/users/1045204/hadas"},"last_editor":{"reputation":2330,"user_id":156767,"user_type":"registered","accept_rate":73,"profile_image":"https://www.gravatar.com/avatar/d771736cfe1b549ecaf0ac00a787d8b7?s=128&d=identicon&r=PG","display_name":"Hounshell","link":"http://stackoverflow.com/users/156767/hounshell"},"comment_count":0,"is_accepted":false,"score":4,"last_activity_date":1414773395,"last_edit_date":1414773395,"creation_date":1330935629,"answer_id":9563535,"question_id":9563479,"body_markdown":"Send the element which fire the event to the function like that:\r\n\r\n $("td").click(function(){marked($(this));\r\n return false;\r\n });\r\nand in the function:\r\n \r\n function marked(td)\r\n {\r\n console.log($(td)); \r\n $(td).addClass("marked");\r\n //....\r\n }\r\n\r\nEdited","link":"http://stackoverflow.com/questions/9563479/how-to-pass-this-properly-in-click-jquery-function/9563535#9563535","body":"<p>Send the element which fire the event to the function like that:</p>\n\n<pre><code>$(\"td\").click(function(){\n marked($(this));\n return false;\n });\n</code></pre>\n\n<p>and in the function:</p>\n\n<pre><code>function marked(td)\n{\n console.log($(td)); \n $(td).addClass(\"marked\");\n //....\n}\n</code></pre>\n"},{"owner":{"reputation":323856,"user_id":69083,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1db0cdfd3fe268e270ec481a73046c2f?s=128&d=identicon&r=PG","display_name":"Guffa","link":"http://stackoverflow.com/users/69083/guffa"},"comments":[{"owner":{"reputation":175763,"user_id":139459,"user_type":"registered","accept_rate":97,"profile_image":"http://i.stack.imgur.com/4Su7A.jpg?s=128&g=1","display_name":"Sarfraz","link":"http://stackoverflow.com/users/139459/sarfraz"},"edited":false,"score":0,"creation_date":1330935880,"post_id":9563542,"comment_id":12123478}],"comment_count":1,"is_accepted":false,"score":0,"last_activity_date":1330935656,"creation_date":1330935656,"answer_id":9563542,"question_id":9563479,"body_markdown":"You can use the `call` method to specify the scope for the function:\r\n\r\n $("td").click(function(){ marked.call(this, listCells); });\r\n\r\nNow the `marked` function can access the clicked element using the `this` keyword.\r\n","link":"http://stackoverflow.com/questions/9563479/how-to-pass-this-properly-in-click-jquery-function/9563542#9563542","body":"<p>You can use the <code>call</code> method to specify the scope for the function:</p>\n\n<pre><code>$(\"td\").click(function(){ marked.call(this, listCells); });\n</code></pre>\n\n<p>Now the <code>marked</code> function can access the clicked element using the <code>this</code> keyword.</p>\n"},{"owner":{"reputation":175763,"user_id":139459,"user_type":"registered","accept_rate":97,"profile_image":"http://i.stack.imgur.com/4Su7A.jpg?s=128&g=1","display_name":"Sarfraz","link":"http://stackoverflow.com/users/139459/sarfraz"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1330935679,"creation_date":1330935679,"answer_id":9563547,"question_id":9563479,"body_markdown":"You need to pass `$(this)` to your function:\r\n\r\n $("td").click(function(){ marked(listCells, $(this))} );\r\n\r\nAnd modify your function like this:\r\n\r\n function marked(arr, that)\r\n {\r\n that.addClass("marked");\r\n \r\n if(turn == TURN_X)\r\n {\r\n that.innerHTML = "X";\r\n turn = false;\r\n }\r\n else\r\n that.innerHTML = "O";\r\n \r\n var tileNum = that.attr("id");\r\n }","link":"http://stackoverflow.com/questions/9563479/how-to-pass-this-properly-in-click-jquery-function/9563547#9563547","body":"<p>You need to pass <code>$(this)</code> to your function:</p>\n\n<pre><code>$(\"td\").click(function(){ marked(listCells, $(this))} );\n</code></pre>\n\n<p>And modify your function like this:</p>\n\n<pre><code>function marked(arr, that)\n{\n that.addClass(\"marked\");\n\n if(turn == TURN_X)\n {\n that.innerHTML = \"X\";\n turn = false;\n }\n else\n that.innerHTML = \"O\";\n\n var tileNum = that.attr(\"id\");\n}\n</code></pre>\n"},{"owner":{"reputation":2207,"user_id":1234595,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/41d913a5bc1693a51e5845ebce6b48c5?s=128&d=identicon&r=PG","display_name":"francisco.preller","link":"http://stackoverflow.com/users/1234595/francisco-preller"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1330935708,"creation_date":1330935708,"answer_id":9563550,"question_id":9563479,"body_markdown":"Try:\r\n\r\n $("td").click(function(event){\r\n marked(listCells, $(this));\r\n });\r\n\r\nThen:\r\n\r\n function marked(arr, sel) {\r\n console.log($(this));\r\n sel.addClass("marked");\r\n\r\n if(turn == TURN_X) {\r\n this.innerHTML = "X";\r\n turn = false;\r\n } else {\r\n this.innerHTML = "O";\r\n }\r\n var tileNum = $(this).attr("id");\r\n }","link":"http://stackoverflow.com/questions/9563479/how-to-pass-this-properly-in-click-jquery-function/9563550#9563550","body":"<p>Try:</p>\n\n<pre><code>$(\"td\").click(function(event){\n marked(listCells, $(this));\n});\n</code></pre>\n\n<p>Then:</p>\n\n<pre><code>function marked(arr, sel) {\n console.log($(this));\n sel.addClass(\"marked\");\n\n if(turn == TURN_X) {\n this.innerHTML = \"X\";\n turn = false;\n } else {\n this.innerHTML = \"O\";\n }\n var tileNum = $(this).attr(\"id\");\n}\n</code></pre>\n"},{"owner":{"reputation":155758,"user_id":18771,"user_type":"registered","accept_rate":81,"profile_image":"https://www.gravatar.com/avatar/0ada184c98bf9073d15b2dc815be0170?s=128&d=identicon&r=PG","display_name":"Tomalak","link":"http://stackoverflow.com/users/18771/tomalak"},"comments":[{"owner":{"reputation":134,"user_id":1028892,"user_type":"registered","accept_rate":81,"profile_image":"https://www.gravatar.com/avatar/117b608a2bcac55e03738c83d102229f?s=128&d=identicon&r=PG","display_name":"wayfare","link":"http://stackoverflow.com/users/1028892/wayfare"},"edited":false,"score":0,"creation_date":1330997955,"post_id":9563668,"comment_id":12143123},{"owner":{"reputation":134,"user_id":1028892,"user_type":"registered","accept_rate":81,"profile_image":"https://www.gravatar.com/avatar/117b608a2bcac55e03738c83d102229f?s=128&d=identicon&r=PG","display_name":"wayfare","link":"http://stackoverflow.com/users/1028892/wayfare"},"edited":false,"score":0,"creation_date":1330998114,"post_id":9563668,"comment_id":12143151},{"owner":{"reputation":155758,"user_id":18771,"user_type":"registered","accept_rate":81,"profile_image":"https://www.gravatar.com/avatar/0ada184c98bf9073d15b2dc815be0170?s=128&d=identicon&r=PG","display_name":"Tomalak","link":"http://stackoverflow.com/users/18771/tomalak"},"reply_to_user":{"reputation":134,"user_id":1028892,"user_type":"registered","accept_rate":81,"profile_image":"https://www.gravatar.com/avatar/117b608a2bcac55e03738c83d102229f?s=128&d=identicon&r=PG","display_name":"wayfare","link":"http://stackoverflow.com/users/1028892/wayfare"},"edited":false,"score":1,"creation_date":1331013680,"post_id":9563668,"comment_id":12145902}],"last_editor":{"reputation":155758,"user_id":18771,"user_type":"registered","accept_rate":81,"profile_image":"https://www.gravatar.com/avatar/0ada184c98bf9073d15b2dc815be0170?s=128&d=identicon&r=PG","display_name":"Tomalak","link":"http://stackoverflow.com/users/18771/tomalak"},"comment_count":3,"is_accepted":true,"score":6,"last_activity_date":1331013552,"last_edit_date":1331013552,"creation_date":1330936479,"answer_id":9563668,"question_id":9563479,"body_markdown":"You code does not follow the right principles.\r\n\r\n $(function(){\r\n var TURN_X = "X",\r\n TURN_O = "O", \r\n turn = TURN_O,\r\n $listCells = $("td");\r\n\r\n function marked() { // define event handler\r\n var $this = $(this),\r\n tileNum = $this.attr("id");\r\n\r\n if ( !($this.hasClass("marked") ) {\r\n $this.addClass("marked").text(turn);\r\n turn = (turn == TURN_X) ? TURN_O : TURN_X;\r\n }\r\n }\r\n\r\n $listCells.click(marked); // attach event handler\r\n });\r\n\r\n1. Wrap everything in the document.ready function. Avoid global variables wherever possible.\r\n1. Make use of the fact that jQuery manages `this` for you. `this` will always be what you expect if you pass callback functions directly instead of calling them yourself.","link":"http://stackoverflow.com/questions/9563479/how-to-pass-this-properly-in-click-jquery-function/9563668#9563668","body":"<p>You code does not follow the right principles.</p>\n\n<pre><code>$(function(){\n var TURN_X = \"X\",\n TURN_O = \"O\", \n turn = TURN_O,\n $listCells = $(\"td\");\n\n function marked() { // define event handler\n var $this = $(this),\n tileNum = $this.attr(\"id\");\n\n if ( !($this.hasClass(\"marked\") ) {\n $this.addClass(\"marked\").text(turn);\n turn = (turn == TURN_X) ? TURN_O : TURN_X;\n }\n }\n\n $listCells.click(marked); // attach event handler\n});\n</code></pre>\n\n<ol>\n<li>Wrap everything in the document.ready function. Avoid global variables wherever possible.</li>\n<li>Make use of the fact that jQuery manages <code>this</code> for you. <code>this</code> will always be what you expect if you pass callback functions directly instead of calling them yourself.</li>\n</ol>\n"},{"owner":{"reputation":135904,"user_id":965051,"user_type":"registered","profile_image":"http://i.stack.imgur.com/XgLe7.gif?s=128&g=1","display_name":"adeneo","link":"http://stackoverflow.com/users/965051/adeneo"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1330940564,"creation_date":1330940564,"answer_id":9564468,"question_id":9563479,"body_markdown":" \r\n\r\n $(document).ready(function(){\r\n var TURN_X = false,\r\n TURN_O = true,\r\n turn = false,\r\n listCells = $.makeArray($("td"));\r\n\r\n $("td").click(function() {\r\n marked(listCells, this)\r\n });\r\n\r\n function marked(arr, self) {\r\n $(self).addClass("marked");\r\n \r\n if(turn == TURN_X) {\r\n self.innerHTML = "X";\r\n turn = false;\r\n }else{\r\n self.innerHTML = "O";\r\n var tileNum = self.id;\r\n }\r\n }\r\n });\r\n\r\n \r\n","link":"http://stackoverflow.com/questions/9563479/how-to-pass-this-properly-in-click-jquery-function/9564468#9564468","body":"<pre><code>$(document).ready(function(){\n var TURN_X = false,\n TURN_O = true,\n turn = false,\n listCells = $.makeArray($(\"td\"));\n\n $(\"td\").click(function() {\n marked(listCells, this)\n });\n\n function marked(arr, self) {\n $(self).addClass(\"marked\");\n\n if(turn == TURN_X) {\n self.innerHTML = \"X\";\n turn = false;\n }else{\n self.innerHTML = \"O\";\n var tileNum = self.id;\n }\n }\n});\n</code></pre>\n"}],"tags":["jquery","click","this"],"owner":{"reputation":134,"user_id":1028892,"user_type":"registered","accept_rate":81,"profile_image":"https://www.gravatar.com/avatar/117b608a2bcac55e03738c83d102229f?s=128&d=identicon&r=PG","display_name":"wayfare","link":"http://stackoverflow.com/users/1028892/wayfare"},"comments":[{"owner":{"reputation":8549,"user_id":1130266,"user_type":"registered","accept_rate":93,"profile_image":"https://www.gravatar.com/avatar/fa2d4040807e58ed5b06867720516e1b?s=128&d=identicon&r=PG","display_name":"Greg","link":"http://stackoverflow.com/users/1130266/greg"},"edited":false,"score":0,"creation_date":1330935845,"post_id":9563479,"comment_id":12123465}],"comment_count":1,"is_answered":true,"view_count":11657,"accepted_answer_id":9563668,"answer_count":7,"score":6,"last_activity_date":1414773395,"creation_date":1330935254,"last_edit_date":1330935600,"question_id":9563479,"body_markdown":"I am trying to make a tictactoe project in jQuery and I am having a major problem...\r\n\r\nThe tiles are in `<td>` tags and I am trying to make it so that when the user clicks the the tile, it calls the "marked" function. \r\n\r\nIf we now look into the "marked" function, `$(this)` is intended to be the `<td>` node that the function was called from. \r\n\r\nHowever, it wasn't doing anything so I checked the console and apparently `$(this)` was containing the DOM Window object. \r\n\r\nIs there anyway I can send the right kind of `$(this)` to the "marked" function?\r\n\r\nThank you!\r\n\r\n <script type="text/javascript">\r\n \r\n var TURN_X = false;\r\n var TURN_O = true;\r\n \r\n var turn = false; // this is to see whos turn it is.\r\n \r\n $(document).ready(function(){\r\n \r\n \t var listCells = $.makeArray($("td"));\r\n \t $("td").click(function(){marked(listCells)}); //THIS IS WHERE I HAVE PROBLEMS\r\n \t return false;\r\n });\r\n \r\n function marked(arr)\r\n {\r\n \t console.log($(this)); // THIS CONSOLE LOG RETURNS "DOM Window"\r\n \t $(this).addClass("marked");\r\n \r\n \t if(turn == TURN_X)\r\n \t {\r\n \t\tthis.innerHTML = "X";\r\n \t\tturn = false;\r\n \t }\r\n \t else\r\n \t\tthis.innerHTML = "O";\r\n \r\n \t var tileNum = $(this).attr("id");\r\n }","link":"http://stackoverflow.com/questions/9563479/how-to-pass-this-properly-in-click-jquery-function","title":"How to pass $(this) properly in click jQuery function","body":"<p>I am trying to make a tictactoe project in jQuery and I am having a major problem...</p>\n\n<p>The tiles are in <code><td></code> tags and I am trying to make it so that when the user clicks the the tile, it calls the \"marked\" function. </p>\n\n<p>If we now look into the \"marked\" function, <code>$(this)</code> is intended to be the <code><td></code> node that the function was called from. </p>\n\n<p>However, it wasn't doing anything so I checked the console and apparently <code>$(this)</code> was containing the DOM Window object. </p>\n\n<p>Is there anyway I can send the right kind of <code>$(this)</code> to the \"marked\" function?</p>\n\n<p>Thank you!</p>\n\n<pre><code><script type=\"text/javascript\">\n\n var TURN_X = false;\n var TURN_O = true;\n\n var turn = false; // this is to see whos turn it is.\n\n $(document).ready(function(){\n\n var listCells = $.makeArray($(\"td\"));\n $(\"td\").click(function(){marked(listCells)}); //THIS IS WHERE I HAVE PROBLEMS\n return false;\n });\n\n function marked(arr)\n {\n console.log($(this)); // THIS CONSOLE LOG RETURNS \"DOM Window\"\n $(this).addClass(\"marked\");\n\n if(turn == TURN_X)\n {\n this.innerHTML = \"X\";\n turn = false;\n }\n else\n this.innerHTML = \"O\";\n\n var tileNum = $(this).attr(\"id\");\n }\n</code></pre>\n"},{"answers":[{"owner":{"reputation":11,"user_id":563002,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5ef32680f5eb641538a98e786ad6c46a?s=128&d=identicon&r=PG","display_name":"softex","link":"http://stackoverflow.com/users/563002/softex"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1294760468,"creation_date":1294760468,"answer_id":4659410,"question_id":4650831,"body_markdown":"\r\nWelll ... turns out the BluetoothChat code re-creates the byte array with *message.getBytes()* before sending to the service. (after all, being **chat** code it would normally source only regular ascii strings) As others on this site have pointed out, getBytes() can create encoding issues in some cases. So, for purposes of sending these extended-ascii commands, I don't mess with strings and just send the byte array to the service with\r\n\r\n private void sendCommand(byte[] cmd) {\r\n \tmChatService.write(cmd);\r\n }\r\n\r\nThe so-called command array is first initialized with placeholders for the hex radio address elements\r\n\r\n byte[] addrArray = {(byte) 0xCC, 16, 0, 0, 0, 13};\r\n\r\nand then filled in with the help of the conversion method\r\n\r\n radioArray = HexStringToByteArray(radioAddr1);\r\n\r\nwhich can be found here: [HexStringToByteArray@stackoverflow][1]\r\n\r\n \r\n\r\n \r\n\r\n\r\n [1]: http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java","link":"http://stackoverflow.com/questions/4650831/how-do-you-send-an-extended-ascii-at-command-cch-from-android-bluetooth-to-a-s/4659410#4659410","body":"<p>Welll ... turns out the BluetoothChat code re-creates the byte array with <em>message.getBytes()</em> before sending to the service. (after all, being <strong>chat</strong> code it would normally source only regular ascii strings) As others on this site have pointed out, getBytes() can create encoding issues in some cases. So, for purposes of sending these extended-ascii commands, I don't mess with strings and just send the byte array to the service with</p>\n\n<pre><code>private void sendCommand(byte[] cmd) {\n mChatService.write(cmd);\n}\n</code></pre>\n\n<p>The so-called command array is first initialized with placeholders for the hex radio address elements</p>\n\n<pre><code>byte[] addrArray = {(byte) 0xCC, 16, 0, 0, 0, 13};\n</code></pre>\n\n<p>and then filled in with the help of the conversion method</p>\n\n<pre><code>radioArray = HexStringToByteArray(radioAddr1);\n</code></pre>\n\n<p>which can be found here: <a href=\"http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java\">HexStringToByteArray@stackoverflow</a></p>\n"}],"tags":["android","bluetooth","serial-port","ascii","at-command"],"owner":{"reputation":11,"user_id":563002,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5ef32680f5eb641538a98e786ad6c46a?s=128&d=identicon&r=PG","display_name":"softex","link":"http://stackoverflow.com/users/563002/softex"},"comment_count":0,"is_answered":false,"view_count":1823,"answer_count":1,"score":0,"last_activity_date":1414773393,"creation_date":1294689028,"last_edit_date":1414773393,"question_id":4650831,"body_markdown":"This one really has me banging my head. I'm sending alphanumeric data from an Android app, through the BluetoothChatService, to a serial bluetooth adaptor connected to the serial input of a radio transceiver.\r\n\r\nEverything works fine except when I try to configure the radio on-the-fly with its AT-commands. The AT+++ (enter command mode) is received OK, but the problem comes with the extended-ascii characters in the next two commands: Changing the radio destination address (which is what I'm trying to do) requires CCh 10h (plus 3 hex radio address bytes), and exiting the command mode requires CCh ATO.\r\n\r\nI know the radio can be configured OK because I've done it on an earlier prototype with the serial commands from PIC basic, and it also can be configured by entering the commands directly from hyperterm. Both these methods somehow convert that pesky CCh into a form the radio understands.\r\n\r\nI've have tried just about everything an Android noob could possibly come up with to finagle the encoding such as:\r\n\r\n private void command_address() {\r\n\t\tbyte[] addrArray = {(byte) 0xCC, 16, 36, 65, 21, 13};\t\t\t\t\t\r\n\t\tCharSequence addrvalues = EncodingUtils.getString(addrArray, "UTF-8");\t\r\n\t\tsendMessage((String) addrvalues);\r\n }\r\n\r\nbut no matter what, I can't seem to get that high-order byte (CCh/204/-52) to behave as it should. All other (< 127) bytes, command or data, transmit with no problem. Any help here would be greatly appreciated.\r\n\r\n-Dave \r\n\r\n\t\t\r\n\r\n\r\n \r\n","link":"http://stackoverflow.com/questions/4650831/how-do-you-send-an-extended-ascii-at-command-cch-from-android-bluetooth-to-a-s","title":"How do you send an extended-ascii AT-command (CCh) from Android bluetooth to a serial device?","body":"<p>This one really has me banging my head. I'm sending alphanumeric data from an Android app, through the BluetoothChatService, to a serial bluetooth adaptor connected to the serial input of a radio transceiver.</p>\n\n<p>Everything works fine except when I try to configure the radio on-the-fly with its AT-commands. The AT+++ (enter command mode) is received OK, but the problem comes with the extended-ascii characters in the next two commands: Changing the radio destination address (which is what I'm trying to do) requires CCh 10h (plus 3 hex radio address bytes), and exiting the command mode requires CCh ATO.</p>\n\n<p>I know the radio can be configured OK because I've done it on an earlier prototype with the serial commands from PIC basic, and it also can be configured by entering the commands directly from hyperterm. Both these methods somehow convert that pesky CCh into a form the radio understands.</p>\n\n<p>I've have tried just about everything an Android noob could possibly come up with to finagle the encoding such as:</p>\n\n<pre><code>private void command_address() {\n byte[] addrArray = {(byte) 0xCC, 16, 36, 65, 21, 13}; \n CharSequence addrvalues = EncodingUtils.getString(addrArray, \"UTF-8\"); \n sendMessage((String) addrvalues);\n}\n</code></pre>\n\n<p>but no matter what, I can't seem to get that high-order byte (CCh/204/-52) to behave as it should. All other (< 127) bytes, command or data, transmit with no problem. Any help here would be greatly appreciated.</p>\n\n<p>-Dave </p>\n"},{"answers":[{"owner":{"reputation":6,"user_id":3880801,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ec8acd655122f5c9c663cd41739d9e5d?s=128&d=identicon&r=PG&f=1","display_name":"Richard Antalík","link":"http://stackoverflow.com/users/3880801/richard-antal%c3%adk"},"comment_count":0,"is_accepted":true,"score":0,"last_activity_date":1414773393,"creation_date":1414773393,"answer_id":26679410,"question_id":26607683,"body_markdown":"After switching to "Live"/production environment everything is running well.\r\n\r\nFirst transaction occured in first 30 minutes, and following ones in about an hour after next_billing_date.\r\n\r\nIn sandbox only first payment was made to this date(ref to data in Q). "Funny" thing is, that not only sandbox, but even their support seems to be broken...\r\n\r\nAlso see http://stackoverflow.com/questions/26562515/tell-paypal-to-automatically-process-the-monthly-payment?rq=1","link":"http://stackoverflow.com/questions/26607683/billing-date-in-paypal-recurrent-payments/26679410#26679410","body":"<p>After switching to \"Live\"/production environment everything is running well.</p>\n\n<p>First transaction occured in first 30 minutes, and following ones in about an hour after next_billing_date.</p>\n\n<p>In sandbox only first payment was made to this date(ref to data in Q). \"Funny\" thing is, that not only sandbox, but even their support seems to be broken...</p>\n\n<p>Also see <a href=\"http://stackoverflow.com/questions/26562515/tell-paypal-to-automatically-process-the-monthly-payment?rq=1\">Tell PayPal to automatically process the monthly payment</a></p>\n"}],"tags":["paypal"],"owner":{"reputation":6,"user_id":3880801,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ec8acd655122f5c9c663cd41739d9e5d?s=128&d=identicon&r=PG&f=1","display_name":"Richard Antalík","link":"http://stackoverflow.com/users/3880801/richard-antal%c3%adk"},"comment_count":0,"is_answered":true,"view_count":24,"accepted_answer_id":26679410,"answer_count":1,"score":1,"last_activity_date":1414773393,"creation_date":1414497174,"last_edit_date":1414771607,"question_id":26607683,"body_markdown":"I am using paypal rest API for recurrent billing.\r\n\r\nIs there any way to predict date for next payment for billing agreement?\r\n\r\nWhen I create & execute agreement, paypal will provide me this info:\r\n\r\n "start_date": "2014-10-26T07:00:00Z",\r\n "cycles_remaining": "1",\r\n "cycles_completed": "0",\r\n "next_billing_date": "2014-10-26T10:00:00Z",\r\n "final_payment_date": "1970-01-01T00:00:00Z",\r\n "failed_payment_count": "0"\r\n\r\nWhen I check transactions after next_billing_date, there is no payment. However, after a longer time a payment arrive and when I retrieve the same agreement, I get this:\r\n\r\n "start_date": "2014-10-26T07:00:00Z",\r\n "agreement_details": {\r\n "outstanding_balance": {\r\n "currency": "USD",\r\n "value": "0.00"\r\n },\r\n "cycles_remaining": "0",\r\n "cycles_completed": "0",\r\n "next_billing_date": "2014-11-26T10:00:00Z",\r\n "last_payment_date": "2014-10-28T05:00:55Z",\r\n "last_payment_amount": {\r\n "currency": "USD",\r\n "value": "0.01"\r\n },\r\n "final_payment_date": "1970-01-01T00:00:00Z",\r\n "failed_payment_count": "0"\r\n\r\nSo the payment was made 1d 19h after the date provided in agreement.\r\n\r\nIf those 'delays' will be max 3 days, it will be OK. But I need to be sure.\r\n\r\nEDIT: I should specify, that this happens in sandbox environment\r\n\r\nThank you.\r\n\r\n","link":"http://stackoverflow.com/questions/26607683/billing-date-in-paypal-recurrent-payments","title":"Billing date in PayPal recurrent payments","body":"<p>I am using paypal rest API for recurrent billing.</p>\n\n<p>Is there any way to predict date for next payment for billing agreement?</p>\n\n<p>When I create & execute agreement, paypal will provide me this info:</p>\n\n<pre><code>\"start_date\": \"2014-10-26T07:00:00Z\",\n\"cycles_remaining\": \"1\",\n\"cycles_completed\": \"0\",\n\"next_billing_date\": \"2014-10-26T10:00:00Z\",\n\"final_payment_date\": \"1970-01-01T00:00:00Z\",\n\"failed_payment_count\": \"0\"\n</code></pre>\n\n<p>When I check transactions after next_billing_date, there is no payment. However, after a longer time a payment arrive and when I retrieve the same agreement, I get this:</p>\n\n<pre><code>\"start_date\": \"2014-10-26T07:00:00Z\",\n\"agreement_details\": {\n \"outstanding_balance\": {\n \"currency\": \"USD\",\n \"value\": \"0.00\"\n },\n \"cycles_remaining\": \"0\",\n \"cycles_completed\": \"0\",\n \"next_billing_date\": \"2014-11-26T10:00:00Z\",\n \"last_payment_date\": \"2014-10-28T05:00:55Z\",\n \"last_payment_amount\": {\n \"currency\": \"USD\",\n \"value\": \"0.01\"\n },\n \"final_payment_date\": \"1970-01-01T00:00:00Z\",\n \"failed_payment_count\": \"0\"\n</code></pre>\n\n<p>So the payment was made 1d 19h after the date provided in agreement.</p>\n\n<p>If those 'delays' will be max 3 days, it will be OK. But I need to be sure.</p>\n\n<p>EDIT: I should specify, that this happens in sandbox environment</p>\n\n<p>Thank you.</p>\n"},{"tags":["php","laravel-4"],"owner":{"reputation":675,"user_id":446691,"user_type":"registered","accept_rate":91,"profile_image":"https://www.gravatar.com/avatar/4b7953ddade6bdc06771618db0eba1af?s=128&d=identicon&r=PG","display_name":"TH1981","link":"http://stackoverflow.com/users/446691/th1981"},"comments":[{"owner":{"reputation":230,"user_id":4106168,"user_type":"registered","profile_image":"http://graph.facebook.com/100002191578411/picture?type=large","display_name":"Jelle Keizer","link":"http://stackoverflow.com/users/4106168/jelle-keizer"},"edited":false,"score":0,"creation_date":1414375483,"post_id":26579538,"comment_id":41777339},{"owner":{"reputation":230,"user_id":4106168,"user_type":"registered","profile_image":"http://graph.facebook.com/100002191578411/picture?type=large","display_name":"Jelle Keizer","link":"http://stackoverflow.com/users/4106168/jelle-keizer"},"edited":false,"score":1,"creation_date":1414375967,"post_id":26579538,"comment_id":41777401},{"owner":{"reputation":22860,"user_id":1317935,"user_type":"registered","accept_rate":98,"profile_image":"https://www.gravatar.com/avatar/e13d2feaca492372fc4e16318dc99b9e?s=128&d=identicon&r=PG","display_name":"The Shift Exchange","link":"http://stackoverflow.com/users/1317935/the-shift-exchange"},"edited":false,"score":0,"creation_date":1414382771,"post_id":26579538,"comment_id":41778724},{"owner":{"reputation":675,"user_id":446691,"user_type":"registered","accept_rate":91,"profile_image":"https://www.gravatar.com/avatar/4b7953ddade6bdc06771618db0eba1af?s=128&d=identicon&r=PG","display_name":"TH1981","link":"http://stackoverflow.com/users/446691/th1981"},"reply_to_user":{"reputation":230,"user_id":4106168,"user_type":"registered","profile_image":"http://graph.facebook.com/100002191578411/picture?type=large","display_name":"Jelle Keizer","link":"http://stackoverflow.com/users/4106168/jelle-keizer"},"edited":false,"score":0,"creation_date":1414419734,"post_id":26579538,"comment_id":41794128},{"owner":{"reputation":675,"user_id":446691,"user_type":"registered","accept_rate":91,"profile_image":"https://www.gravatar.com/avatar/4b7953ddade6bdc06771618db0eba1af?s=128&d=identicon&r=PG","display_name":"TH1981","link":"http://stackoverflow.com/users/446691/th1981"},"reply_to_user":{"reputation":22860,"user_id":1317935,"user_type":"registered","accept_rate":98,"profile_image":"https://www.gravatar.com/avatar/e13d2feaca492372fc4e16318dc99b9e?s=128&d=identicon&r=PG","display_name":"The Shift Exchange","link":"http://stackoverflow.com/users/1317935/the-shift-exchange"},"edited":false,"score":0,"creation_date":1414419755,"post_id":26579538,"comment_id":41794140}],"comment_count":5,"is_answered":false,"view_count":22,"bounty_amount":150,"bounty_closes_date":1415378189,"answer_count":0,"score":0,"last_activity_date":1414773389,"creation_date":1414369244,"question_id":26579538,"body_markdown":"I'm lost on what I'm doing wrong, and I can't see anyone else with this problem, so it's gotta be me.\r\n\r\nI've just setup `Indatus\\Dispatcher\\ServiceProvider` and have everything running just fine. For testing purposes, I'm just running a single scheduled event every 5 minutes to add a log entry. \r\n\r\nFor some reason, it's duplicating the log entries. \r\n\r\nHere's what the output is looking like: \r\n\r\n\t[2014-10-26 19:00:15] local.INFO: This is a test [] []\r\n\t[2014-10-26 19:00:15] local.INFO: This is a test [] []\r\n\t[2014-10-26 19:05:12] local.INFO: This is a test [] []\r\n\t[2014-10-26 19:05:13] local.INFO: This is a test [] []\r\n\t[2014-10-26 19:10:09] local.INFO: This is a test [] []\r\n\t[2014-10-26 19:10:10] local.INFO: This is a test [] []\r\n\r\nHere's the actual scheduled `fire()` event: \r\n\r\n\tpublic function fire()\r\n\t{\r\n\t\tLog::info('This is a test');\r\n\t}\r\n\r\nThe `schedule()` :\r\n\r\n\tpublic function schedule(Schedulable $scheduler)\r\n\t{\r\n\t\treturn $scheduler->everyMinutes(5);\r\n\r\n\t}\r\n\r\nand I've checked the `scheduled:summary` and it's only showing once: \r\n\r\n\t+----------------+------------------+-----------+--------+------+--------------+-------+-------------+--------+\r\n\t| Environment(s) | Name | Args/Opts | Minute | Hour | Day of Month | Month | Day of Week | Run as |\r\n\t+----------------+------------------+-----------+--------+------+--------------+-------+-------------+--------+\r\n\t| * | schedule:test | | */5 | * | * | * | * | |\r\n\t+----------------+------------------+-----------+--------+------+--------------+-------+-------------+--------+\r\n\r\nAnd finally my crontab entry, which is only listed in the file once:\r\n\r\n\t* * * * * php /vagrant/myapp/artisan scheduled:run 1>> /dev/null 2>&1\r\n\r\nI can't see any duplication that would cause it to run twice. \r\n\r\nAny ideas what I've got wrong?","link":"http://stackoverflow.com/questions/26579538/dispatcher-w-laravel-duplicating-output","title":"Dispatcher w/ Laravel duplicating output","body":"<p>I'm lost on what I'm doing wrong, and I can't see anyone else with this problem, so it's gotta be me.</p>\n\n<p>I've just setup <code>Indatus\\Dispatcher\\ServiceProvider</code> and have everything running just fine. For testing purposes, I'm just running a single scheduled event every 5 minutes to add a log entry. </p>\n\n<p>For some reason, it's duplicating the log entries. </p>\n\n<p>Here's what the output is looking like: </p>\n\n<pre><code>[2014-10-26 19:00:15] local.INFO: This is a test [] []\n[2014-10-26 19:00:15] local.INFO: This is a test [] []\n[2014-10-26 19:05:12] local.INFO: This is a test [] []\n[2014-10-26 19:05:13] local.INFO: This is a test [] []\n[2014-10-26 19:10:09] local.INFO: This is a test [] []\n[2014-10-26 19:10:10] local.INFO: This is a test [] []\n</code></pre>\n\n<p>Here's the actual scheduled <code>fire()</code> event: </p>\n\n<pre><code>public function fire()\n{\n Log::info('This is a test');\n}\n</code></pre>\n\n<p>The <code>schedule()</code> :</p>\n\n<pre><code>public function schedule(Schedulable $scheduler)\n{\n return $scheduler->everyMinutes(5);\n\n}\n</code></pre>\n\n<p>and I've checked the <code>scheduled:summary</code> and it's only showing once: </p>\n\n<pre><code>+----------------+------------------+-----------+--------+------+--------------+-------+-------------+--------+\n| Environment(s) | Name | Args/Opts | Minute | Hour | Day of Month | Month | Day of Week | Run as |\n+----------------+------------------+-----------+--------+------+--------------+-------+-------------+--------+\n| * | schedule:test | | */5 | * | * | * | * | |\n+----------------+------------------+-----------+--------+------+--------------+-------+-------------+--------+\n</code></pre>\n\n<p>And finally my crontab entry, which is only listed in the file once:</p>\n\n<pre><code>* * * * * php /vagrant/myapp/artisan scheduled:run 1>> /dev/null 2>&1\n</code></pre>\n\n<p>I can't see any duplication that would cause it to run twice. </p>\n\n<p>Any ideas what I've got wrong?</p>\n"},{"tags":["java","netbeans","project"],"owner":{"reputation":1,"user_id":4165262,"user_type":"registered","profile_image":"http://graph.facebook.com/100003759045779/picture?type=large","display_name":"Prabhjot Singh","link":"http://stackoverflow.com/users/4165262/prabhjot-singh"},"comments":[{"owner":{"reputation":1150,"user_id":763029,"user_type":"registered","accept_rate":93,"profile_image":"http://i.stack.imgur.com/TVwEa.jpg?s=128&g=1","display_name":"Coffee","link":"http://stackoverflow.com/users/763029/coffee"},"edited":false,"score":1,"creation_date":1414773312,"post_id":26679347,"comment_id":41957659}],"comment_count":1,"is_answered":false,"view_count":11,"answer_count":0,"score":-3,"last_activity_date":1414773379,"creation_date":1414773165,"last_edit_date":1414773379,"question_id":26679347,"body_markdown":"I was working to make a **java** project but its difficult to program the whole code. \r\n\r\nShould I prefer GUI builder of **netbeans** for making this project","link":"http://stackoverflow.com/questions/26679347/is-it-good-to-make-project-just-with-the-help-of-gui-builder-of-netbeans","title":"Is it good to make project just with the help of GUI builder of netbeans","body":"<p>I was working to make a <strong>java</strong> project but its difficult to program the whole code. </p>\n\n<p>Should I prefer GUI builder of <strong>netbeans</strong> for making this project</p>\n"},{"answers":[{"owner":{"reputation":33462,"user_id":201078,"user_type":"registered","accept_rate":86,"profile_image":"https://www.gravatar.com/avatar/98bc153d15df866873e678ec8dc553ac?s=128&d=identicon&r=PG","display_name":"TrueBlueAussie","link":"http://stackoverflow.com/users/201078/trueblueaussie"},"comments":[{"owner":{"reputation":20,"user_id":1318227,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2f243f0da6c1d00f22f32f22d4b0fa4d?s=128&d=identicon&r=PG","display_name":"SouPress","link":"http://stackoverflow.com/users/1318227/soupress"},"edited":false,"score":0,"creation_date":1414772772,"post_id":26679054,"comment_id":41957377},{"owner":{"reputation":33462,"user_id":201078,"user_type":"registered","accept_rate":86,"profile_image":"https://www.gravatar.com/avatar/98bc153d15df866873e678ec8dc553ac?s=128&d=identicon&r=PG","display_name":"TrueBlueAussie","link":"http://stackoverflow.com/users/201078/trueblueaussie"},"reply_to_user":{"reputation":20,"user_id":1318227,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2f243f0da6c1d00f22f32f22d4b0fa4d?s=128&d=identicon&r=PG","display_name":"SouPress","link":"http://stackoverflow.com/users/1318227/soupress"},"edited":false,"score":1,"creation_date":1414773091,"post_id":26679054,"comment_id":41957545},{"owner":{"reputation":33462,"user_id":201078,"user_type":"registered","accept_rate":86,"profile_image":"https://www.gravatar.com/avatar/98bc153d15df866873e678ec8dc553ac?s=128&d=identicon&r=PG","display_name":"TrueBlueAussie","link":"http://stackoverflow.com/users/201078/trueblueaussie"},"reply_to_user":{"reputation":20,"user_id":1318227,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2f243f0da6c1d00f22f32f22d4b0fa4d?s=128&d=identicon&r=PG","display_name":"SouPress","link":"http://stackoverflow.com/users/1318227/soupress"},"edited":false,"score":0,"creation_date":1414773410,"post_id":26679054,"comment_id":41957706},{"owner":{"reputation":20,"user_id":1318227,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2f243f0da6c1d00f22f32f22d4b0fa4d?s=128&d=identicon&r=PG","display_name":"SouPress","link":"http://stackoverflow.com/users/1318227/soupress"},"edited":false,"score":0,"creation_date":1414773424,"post_id":26679054,"comment_id":41957715}],"last_editor":{"reputation":33462,"user_id":201078,"user_type":"registered","accept_rate":86,"profile_image":"https://www.gravatar.com/avatar/98bc153d15df866873e678ec8dc553ac?s=128&d=identicon&r=PG","display_name":"TrueBlueAussie","link":"http://stackoverflow.com/users/201078/trueblueaussie"},"comment_count":4,"is_accepted":false,"score":0,"last_activity_date":1414773375,"last_edit_date":1414773375,"creation_date":1414772161,"answer_id":26679054,"question_id":26678572,"body_markdown":"Basically you want to know \r\n\r\n - What the errors were and\r\n - When every ajax request is finished\r\n\r\nIf you push the errors into a list, the results will be ready at the end (order not guaranteed of course).\r\n\r\nFor the second part, if you keep an array of the ajax promises returned from each $.ajax you can use `$.when` and wait for them all to complete using `always()`.\r\n\r\nAs a basic example (other details removed):\r\n\r\n var listing = {}; // data from reddit API\r\n var promises = [];\r\n var results = [];\r\n $.each(listing, function(key, value) {\r\n // [snip]\r\n promises.push($.ajax({\r\n type: "HEAD",\r\n url: "https://gdata.youtube.com/feeds/api/videos/" + videoID,\r\n error: function() { \r\n //[snip]\r\n results.push({\r\n itemArtist: itemArtist,\r\n videoID: videoID,\r\n url: itemURL});\r\n }\r\n });\r\n );\r\n }\r\n // Wait for all promises to complete (pass or fail) \r\n $.when.apply($, promises).always(function(){\r\n // process list of failed URLs\r\n });\r\n\r\n*Apologies for any typos. This was coded straight into the answer, but you get the idea.*\r\n\r\nI note you mention 100s of requests, but the browser will only allow a handful through at a time, so no need for additional processing.\r\n\r\nIf `always` is not working you can add your own deferred objects that resolve on `success` *or* `fail`:\r\n\r\n var listing = {}; // data from reddit API\r\n var promises = [];\r\n var results = [];\r\n $.each(listing, function(key, value) {\r\n var deferred = $.Deferred();\r\n promises.push(deferred.promise());\r\n // [snip]\r\n $.ajax({\r\n type: "HEAD",\r\n url: "https://gdata.youtube.com/feeds/api/videos/" + videoID,\r\n complete: function(){\r\n // resolve on success or fail\r\n deferred.resolve();\r\n },\r\n error: function() { \r\n //[snip]\r\n results.push({\r\n itemArtist: itemArtist,\r\n videoID: videoID,\r\n url: itemURL});\r\n }\r\n });\r\n );\r\n }\r\n // Wait for all promises to complete (pass or fail) \r\n $.when.apply($, promises).always(function(){\r\n // process list of failed URLs\r\n });\r\n","link":"http://stackoverflow.com/questions/26678572/how-to-keep-ajax-async-inside-each-loop-but-react-to-result-on-each-iter/26679054#26679054","body":"<p>Basically you want to know </p>\n\n<ul>\n<li>What the errors were and</li>\n<li>When every ajax request is finished</li>\n</ul>\n\n<p>If you push the errors into a list, the results will be ready at the end (order not guaranteed of course).</p>\n\n<p>For the second part, if you keep an array of the ajax promises returned from each $.ajax you can use <code>$.when</code> and wait for them all to complete using <code>always()</code>.</p>\n\n<p>As a basic example (other details removed):</p>\n\n<pre><code>var listing = {}; // data from reddit API\nvar promises = [];\nvar results = [];\n$.each(listing, function(key, value) {\n // [snip]\n promises.push($.ajax({\n type: \"HEAD\",\n url: \"https://gdata.youtube.com/feeds/api/videos/\" + videoID,\n error: function() { \n //[snip]\n results.push({\n itemArtist: itemArtist,\n videoID: videoID,\n url: itemURL});\n }\n });\n );\n}\n// Wait for all promises to complete (pass or fail) \n$.when.apply($, promises).always(function(){\n // process list of failed URLs\n});\n</code></pre>\n\n<p><em>Apologies for any typos. This was coded straight into the answer, but you get the idea.</em></p>\n\n<p>I note you mention 100s of requests, but the browser will only allow a handful through at a time, so no need for additional processing.</p>\n\n<p>If <code>always</code> is not working you can add your own deferred objects that resolve on <code>success</code> <em>or</em> <code>fail</code>:</p>\n\n<pre><code>var listing = {}; // data from reddit API\nvar promises = [];\nvar results = [];\n$.each(listing, function(key, value) {\n var deferred = $.Deferred();\n promises.push(deferred.promise());\n // [snip]\n $.ajax({\n type: \"HEAD\",\n url: \"https://gdata.youtube.com/feeds/api/videos/\" + videoID,\n complete: function(){\n // resolve on success or fail\n deferred.resolve();\n },\n error: function() { \n //[snip]\n results.push({\n itemArtist: itemArtist,\n videoID: videoID,\n url: itemURL});\n }\n });\n );\n}\n// Wait for all promises to complete (pass or fail) \n$.when.apply($, promises).always(function(){\n // process list of failed URLs\n});\n</code></pre>\n"}],"tags":["javascript","jquery","ajax","youtube","bookmarklet"],"owner":{"reputation":20,"user_id":1318227,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2f243f0da6c1d00f22f32f22d4b0fa4d?s=128&d=identicon&r=PG","display_name":"SouPress","link":"http://stackoverflow.com/users/1318227/soupress"},"comments":[{"owner":{"reputation":283,"user_id":2653351,"user_type":"registered","accept_rate":81,"profile_image":"https://www.gravatar.com/avatar/24755d808ec7166297fabe5d22f9f757?s=128&d=identicon&r=PG","display_name":"MightyLampshade","link":"http://stackoverflow.com/users/2653351/mightylampshade"},"edited":false,"score":0,"creation_date":1414771335,"post_id":26678572,"comment_id":41956611},{"owner":{"reputation":1037,"user_id":572827,"user_type":"registered","accept_rate":62,"profile_image":"http://i.stack.imgur.com/46MgM.jpg?s=128&g=1","display_name":"LShetty","link":"http://stackoverflow.com/users/572827/lshetty"},"edited":false,"score":0,"creation_date":1414771800,"post_id":26678572,"comment_id":41956876},{"owner":{"reputation":33462,"user_id":201078,"user_type":"registered","accept_rate":86,"profile_image":"https://www.gravatar.com/avatar/98bc153d15df866873e678ec8dc553ac?s=128&d=identicon&r=PG","display_name":"TrueBlueAussie","link":"http://stackoverflow.com/users/201078/trueblueaussie"},"reply_to_user":{"reputation":1037,"user_id":572827,"user_type":"registered","accept_rate":62,"profile_image":"http://i.stack.imgur.com/46MgM.jpg?s=128&g=1","display_name":"LShetty","link":"http://stackoverflow.com/users/572827/lshetty"},"edited":false,"score":0,"creation_date":1414771894,"post_id":26678572,"comment_id":41956935},{"owner":{"reputation":1037,"user_id":572827,"user_type":"registered","accept_rate":62,"profile_image":"http://i.stack.imgur.com/46MgM.jpg?s=128&g=1","display_name":"LShetty","link":"http://stackoverflow.com/users/572827/lshetty"},"reply_to_user":{"reputation":33462,"user_id":201078,"user_type":"registered","accept_rate":86,"profile_image":"https://www.gravatar.com/avatar/98bc153d15df866873e678ec8dc553ac?s=128&d=identicon&r=PG","display_name":"TrueBlueAussie","link":"http://stackoverflow.com/users/201078/trueblueaussie"},"edited":false,"score":0,"creation_date":1414772003,"post_id":26678572,"comment_id":41957001},{"owner":{"reputation":33462,"user_id":201078,"user_type":"registered","accept_rate":86,"profile_image":"https://www.gravatar.com/avatar/98bc153d15df866873e678ec8dc553ac?s=128&d=identicon&r=PG","display_name":"TrueBlueAussie","link":"http://stackoverflow.com/users/201078/trueblueaussie"},"reply_to_user":{"reputation":1037,"user_id":572827,"user_type":"registered","accept_rate":62,"profile_image":"http://i.stack.imgur.com/46MgM.jpg?s=128&g=1","display_name":"LShetty","link":"http://stackoverflow.com/users/572827/lshetty"},"edited":false,"score":0,"creation_date":1414772050,"post_id":26678572,"comment_id":41957029}],"comment_count":5,"is_answered":false,"view_count":37,"answer_count":1,"score":0,"last_activity_date":1414773375,"creation_date":1414770488,"question_id":26678572,"body_markdown":"I'm having trouble with some dumb architecture because I'm dumb. I'm trying to loop over YouTube videos posted to Reddit, extract URLs and process them into an .m3u playlist.\r\n\r\nFull code at [**Subreddit to YouTube Source Bookmarklet** - Play YouTube music from subreddits in Foobar with foo_youtube](https://gist.github.com/akaleeroy/b3de63c46ee43d413913)\r\n\r\nAt some point I get the idea that I could check each URL to see if the video is dead or not, and offer an alternative if they're removed.\r\n\r\nSo I do AJAX requests to YouTube API and if there's an error I'm supposed to react to it and change that item's URL. \r\n\r\nBut the problem is it only works if the AJAX is NOT async - this takes many seconds, during which the page is jammed.\r\n\r\nI'd like to let the AJAX be async but I don't know how I should structure my code.\r\n\r\nHere is **PSEUDOCODE** of how it is now:\r\n\r\n\r\n<!-- language: lang-js -->\r\n\r\n var listing = // data from reddit API\r\n $.each(listing, function(key, value) {\r\n var url = // post URL from reddit posts listing \r\n // ( "http://youtu.be/XmQR4_hDtpY&amp;hd=1" )\r\n var aRegex = // to parse YouTube URLs \r\n // ( (?:youtube(?:-nocookie)?.com/....bla...bla )\r\n var videoID = // YouTube video ID, extracted with regex \r\n // ( "XmQR4_hDtpY" )\r\n var itemArtist = // parsed from reddit posts listing \r\n // ( "Awesome Artist" )\r\n var itemTitle = // parsed from reddit posts listing \r\n // ( "Cool Song (Original Mix)" )\r\n var itemURL = // url, further processed \r\n // ( "3dydfy://www.youtube.com/watch?v=XmQR4_hDtpY&hd=1" )\r\n\r\n $.ajax({\r\n type: "HEAD",\r\n url: "https://gdata.youtube.com/feeds/api/videos/" + videoID,\r\n error: function() { \r\n // If it's no longer available \r\n // (removed, deleted account, made private)\r\n deadVid++; // chalk up another dead one, for showing progress\r\n itemURL = // dead videos should get a different URL \r\n // ( "3dydfy-search://q=Awesome%20Artist%20Cool%20Song....." )\r\n }\r\n });\r\n\r\n // further process itemURL!\r\n // at this point I want itemURL changed by the .ajax()'s error callback\r\n // but I'm trying to keep the requests async \r\n // to not jam the page while a hundred HTTP requests happen!\r\n if (condition){\r\n itemURL += // append various strings\r\n }\r\n // Write the item to the .m3u8 playlist\r\n playlist += itemURL + '\\n';\r\n }// end .each()","link":"http://stackoverflow.com/questions/26678572/how-to-keep-ajax-async-inside-each-loop-but-react-to-result-on-each-iter","title":"How to keep $.ajax() async inside $.each() loop but react to result on each iteration","body":"<p>I'm having trouble with some dumb architecture because I'm dumb. I'm trying to loop over YouTube videos posted to Reddit, extract URLs and process them into an .m3u playlist.</p>\n\n<p>Full code at <a href=\"https://gist.github.com/akaleeroy/b3de63c46ee43d413913\" rel=\"nofollow\"><strong>Subreddit to YouTube Source Bookmarklet</strong> - Play YouTube music from subreddits in Foobar with foo_youtube</a></p>\n\n<p>At some point I get the idea that I could check each URL to see if the video is dead or not, and offer an alternative if they're removed.</p>\n\n<p>So I do AJAX requests to YouTube API and if there's an error I'm supposed to react to it and change that item's URL. </p>\n\n<p>But the problem is it only works if the AJAX is NOT async - this takes many seconds, during which the page is jammed.</p>\n\n<p>I'd like to let the AJAX be async but I don't know how I should structure my code.</p>\n\n<p>Here is <strong>PSEUDOCODE</strong> of how it is now:</p>\n\n<pre class=\"lang-js prettyprint-override\"><code>var listing = // data from reddit API\n$.each(listing, function(key, value) {\n var url = // post URL from reddit posts listing \n // ( \"http://youtu.be/XmQR4_hDtpY&amp;hd=1\" )\n var aRegex = // to parse YouTube URLs \n // ( (?:youtube(?:-nocookie)?.com/....bla...bla )\n var videoID = // YouTube video ID, extracted with regex \n // ( \"XmQR4_hDtpY\" )\n var itemArtist = // parsed from reddit posts listing \n // ( \"Awesome Artist\" )\n var itemTitle = // parsed from reddit posts listing \n // ( \"Cool Song (Original Mix)\" )\n var itemURL = // url, further processed \n // ( \"3dydfy://www.youtube.com/watch?v=XmQR4_hDtpY&hd=1\" )\n\n $.ajax({\n type: \"HEAD\",\n url: \"https://gdata.youtube.com/feeds/api/videos/\" + videoID,\n error: function() { \n // If it's no longer available \n // (removed, deleted account, made private)\n deadVid++; // chalk up another dead one, for showing progress\n itemURL = // dead videos should get a different URL \n // ( \"3dydfy-search://q=Awesome%20Artist%20Cool%20Song.....\" )\n }\n });\n\n // further process itemURL!\n // at this point I want itemURL changed by the .ajax()'s error callback\n // but I'm trying to keep the requests async \n // to not jam the page while a hundred HTTP requests happen!\n if (condition){\n itemURL += // append various strings\n }\n // Write the item to the .m3u8 playlist\n playlist += itemURL + '\\n';\n}// end .each()\n</code></pre>\n"},{"answers":[{"owner":{"reputation":42,"user_id":3766533,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/f034ad2421e09b3fa359aef7e0455a86?s=128&d=identicon&r=PG&f=1","display_name":"bandrzejczak","link":"http://stackoverflow.com/users/3766533/bandrzejczak"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773374,"creation_date":1414773374,"answer_id":26679409,"question_id":26679110,"body_markdown":"You have three options here:\r\n\r\n - Either you'll orther your parameters so that when you want to use param 5, you're sure, that previous params must also be defined\r\n - Or you can just use some character that represents null, like -, or something. Your URL would look like `/buildings/5/-/red`\r\n - Or (the best option) you *should* leave obligatory parameters in URL (like IDs) and put optional parameters in URL get parameters (like you showed in oldschool style parameters). Then your URL would look like this: `/buildings/5?color=red`. You can access those parameters from AngularJS using `$location.search().color` etc. ","link":"http://stackoverflow.com/questions/26679110/ngroute-support-for-multiple-url-parameters/26679409#26679409","body":"<p>You have three options here:</p>\n\n<ul>\n<li>Either you'll orther your parameters so that when you want to use param 5, you're sure, that previous params must also be defined</li>\n<li>Or you can just use some character that represents null, like -, or something. Your URL would look like <code>/buildings/5/-/red</code></li>\n<li>Or (the best option) you <em>should</em> leave obligatory parameters in URL (like IDs) and put optional parameters in URL get parameters (like you showed in oldschool style parameters). Then your URL would look like this: <code>/buildings/5?color=red</code>. You can access those parameters from AngularJS using <code>$location.search().color</code> etc. </li>\n</ul>\n"}],"tags":["javascript","angularjs"],"owner":{"reputation":475,"user_id":619303,"user_type":"registered","accept_rate":58,"profile_image":"https://www.gravatar.com/avatar/2cac83e729b2bacee432797a5b4bfac3?s=128&d=identicon&r=PG","display_name":"omer bach","link":"http://stackoverflow.com/users/619303/omer-bach"},"comment_count":0,"is_answered":false,"view_count":10,"answer_count":1,"score":-1,"last_activity_date":1414773374,"creation_date":1414772339,"question_id":26679110,"body_markdown":"I have a major gap in operating ng routing functionalists.\r\nHere is what I want to achieve: I have a main page which directs to dashboard.html and another \r\nbuildings.html. \r\nThe buildings page could be called with many parameters, such as: id, type, color\r\nSo a traditional url would look like that: \r\n\r\n /buildings?id=110&type=special&color=red\r\n\r\nSo as far as I understand in angular ngroute I should have this structure: \r\n\r\n $routeProvider\r\n \t\t\t\r\n \t\t\t// route for the main page which will direct to the buildings page\r\n \t\t\t.when('/', {\r\n \t\t\t\ttemplateUrl : 'web/pages/dashboard.html',\r\n \t\t\t\tcontroller : 'dashboardController',\r\n \t\t\t\tcontrollerAs : 'dashboard'\r\n \t\t\t})\r\n \t\t\t\r\n \t\t\t// route for the main page which will direct to the buildings page\r\n \t\t\t.when('/buildings/:buildingId/:buildingType/:buildingColor', {\r\n \t\t\t\ttemplateUrl : 'web/pages/buildings.html',\r\n \t\t\t\tcontroller : 'mainController',\r\n \t\t\t\tcontrollerAs : 'buildings'\r\n \t\t\t})\r\n ;\r\n \t\t\t\r\n });\t\r\n\r\nAnd the url should be like:\r\n\r\n /buildings/110/special/red\r\n\r\n\r\nWhat I don't get is how to call for the buildings page with only id or with type and color?\r\nAnd if I have 7 parameters and want to trigger a call with only 3, how should I do that?\r\n\r\nI'm using $location.path to shift between pages when needed based on gui events, for example:\r\n$location.path( '/buildings/'+$scope.id);\r\n\r\nThanks.","link":"http://stackoverflow.com/questions/26679110/ngroute-support-for-multiple-url-parameters","title":"ngroute support for multiple url parameters","body":"<p>I have a major gap in operating ng routing functionalists.\nHere is what I want to achieve: I have a main page which directs to dashboard.html and another \nbuildings.html. \nThe buildings page could be called with many parameters, such as: id, type, color\nSo a traditional url would look like that: </p>\n\n<pre><code>/buildings?id=110&type=special&color=red\n</code></pre>\n\n<p>So as far as I understand in angular ngroute I should have this structure: </p>\n\n<pre><code>$routeProvider\n\n // route for the main page which will direct to the buildings page\n .when('/', {\n templateUrl : 'web/pages/dashboard.html',\n controller : 'dashboardController',\n controllerAs : 'dashboard'\n })\n\n // route for the main page which will direct to the buildings page\n .when('/buildings/:buildingId/:buildingType/:buildingColor', {\n templateUrl : 'web/pages/buildings.html',\n controller : 'mainController',\n controllerAs : 'buildings'\n })\n ;\n\n}); \n</code></pre>\n\n<p>And the url should be like:</p>\n\n<pre><code>/buildings/110/special/red\n</code></pre>\n\n<p>What I don't get is how to call for the buildings page with only id or with type and color?\nAnd if I have 7 parameters and want to trigger a call with only 3, how should I do that?</p>\n\n<p>I'm using $location.path to shift between pages when needed based on gui events, for example:\n$location.path( '/buildings/'+$scope.id);</p>\n\n<p>Thanks.</p>\n"},{"answers":[{"owner":{"reputation":5649,"user_id":1071684,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/089af77f838033f2f970a68f1598109c?s=128&d=identicon&r=PG","display_name":"Dor Shemer","link":"http://stackoverflow.com/users/1071684/dor-shemer"},"comments":[{"owner":{"reputation":1701,"user_id":473961,"user_type":"registered","accept_rate":33,"profile_image":"https://www.gravatar.com/avatar/28da63e58ce7fa428494292973747c84?s=128&d=identicon&r=PG","display_name":"Jess Telford","link":"http://stackoverflow.com/users/473961/jess-telford"},"edited":false,"score":0,"creation_date":1352431746,"post_id":9558954,"comment_id":18139984},{"owner":{"reputation":1701,"user_id":473961,"user_type":"registered","accept_rate":33,"profile_image":"https://www.gravatar.com/avatar/28da63e58ce7fa428494292973747c84?s=128&d=identicon&r=PG","display_name":"Jess Telford","link":"http://stackoverflow.com/users/473961/jess-telford"},"edited":false,"score":1,"creation_date":1352432294,"post_id":9558954,"comment_id":18140116},{"owner":{"reputation":445,"user_id":411615,"user_type":"registered","accept_rate":84,"profile_image":"http://i.stack.imgur.com/7vbPQ.jpg?s=128&g=1","display_name":"Deckard","link":"http://stackoverflow.com/users/411615/deckard"},"edited":false,"score":0,"creation_date":1400146209,"post_id":9558954,"comment_id":36369430},{"owner":{"reputation":5649,"user_id":1071684,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/089af77f838033f2f970a68f1598109c?s=128&d=identicon&r=PG","display_name":"Dor Shemer","link":"http://stackoverflow.com/users/1071684/dor-shemer"},"reply_to_user":{"reputation":445,"user_id":411615,"user_type":"registered","accept_rate":84,"profile_image":"http://i.stack.imgur.com/7vbPQ.jpg?s=128&g=1","display_name":"Deckard","link":"http://stackoverflow.com/users/411615/deckard"},"edited":false,"score":0,"creation_date":1413808358,"post_id":9558954,"comment_id":41569422}],"last_editor":{"reputation":5649,"user_id":1071684,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/089af77f838033f2f970a68f1598109c?s=128&d=identicon&r=PG","display_name":"Dor Shemer","link":"http://stackoverflow.com/users/1071684/dor-shemer"},"comment_count":4,"is_accepted":true,"score":31,"last_activity_date":1330896721,"last_edit_date":1330896721,"creation_date":1330896366,"answer_id":9558954,"question_id":9558867,"body_markdown":"Use `-s` and `-N`:\r\n\r\n > id=`mysql -uroot -ppwd -s -N -e "SELECT id FROM nagios.host WHERE name='$host'"`\r\n > echo $id\r\n 0\r\n\r\nFrom the manual:\r\n\r\n\r\n> --silent, -s\r\n> \r\n> Silent mode. Produce less output. This option can be given multiple\r\n> times to produce less and less output.\r\n> \r\n> This option results in nontabular output format and escaping of\r\n> special characters. Escaping may be disabled by using raw mode; see\r\n> the description for the --raw option.\r\n> \r\n> --skip-column-names, -N\r\n> \r\n> Do not write column names in results.\r\n\r\n**EDIT**\r\n\r\nLooks like `-ss` works as well and much easier to remember.","link":"http://stackoverflow.com/questions/9558867/how-to-fetch-field-from-mysql-query-result-in-bash/9558954#9558954","body":"<p>Use <code>-s</code> and <code>-N</code>:</p>\n\n<pre><code>> id=`mysql -uroot -ppwd -s -N -e \"SELECT id FROM nagios.host WHERE name='$host'\"`\n> echo $id\n0\n</code></pre>\n\n<p>From the manual:</p>\n\n<blockquote>\n <p>--silent, -s</p>\n\n<pre><code> Silent mode. Produce less output. This option can be given multiple\n times to produce less and less output.\n\n This option results in nontabular output format and escaping of\n special characters. Escaping may be disabled by using raw mode; see\n the description for the --raw option.\n</code></pre>\n \n <p>--skip-column-names, -N</p>\n\n<pre><code> Do not write column names in results.\n</code></pre>\n</blockquote>\n\n<p><strong>EDIT</strong></p>\n\n<p>Looks like <code>-ss</code> works as well and much easier to remember.</p>\n"},{"owner":{"reputation":197,"user_id":661440,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/bd32692c3bb8c4161d4e78c9041abb69?s=128&d=identicon&r=PG","display_name":"corgi","link":"http://stackoverflow.com/users/661440/corgi"},"comment_count":0,"is_accepted":false,"score":1,"last_activity_date":1330896439,"creation_date":1330896439,"answer_id":9558956,"question_id":9558867,"body_markdown":"Try:\r\n\r\n mysql -B --column-names=0 -uroot -ppwd -e "SELECT id FROM nagios.host WHERE name='$host'"\r\n\r\n-B will print results using tab as the column separator and \r\n\r\n--column-names=0 will disable the headers.","link":"http://stackoverflow.com/questions/9558867/how-to-fetch-field-from-mysql-query-result-in-bash/9558956#9558956","body":"<p>Try:</p>\n\n<pre><code>mysql -B --column-names=0 -uroot -ppwd -e \"SELECT id FROM nagios.host WHERE name='$host'\"\n</code></pre>\n\n<p>-B will print results using tab as the column separator and </p>\n\n<p>--column-names=0 will disable the headers.</p>\n"},{"owner":{"reputation":156,"user_id":1307507,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b988bb2d4741f1451444d8115ce5b3f8?s=128&d=identicon&r=PG","display_name":"Marcelo Amorim","link":"http://stackoverflow.com/users/1307507/marcelo-amorim"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1371067057,"creation_date":1371067057,"answer_id":17074180,"question_id":9558867,"body_markdown":"I tried the solutions but always received empty response.\r\n\r\nIn my case the solution was:\r\n\r\n\r\n #!/bin/sh\r\n\r\n FIELDVALUE=$(mysql -ss -N -e "SELECT field FROM db.table where fieldwhere = '$2'")\r\n\r\n echo $FIELDVALUE","link":"http://stackoverflow.com/questions/9558867/how-to-fetch-field-from-mysql-query-result-in-bash/17074180#17074180","body":"<p>I tried the solutions but always received empty response.</p>\n\n<p>In my case the solution was:</p>\n\n<pre><code>#!/bin/sh\n\nFIELDVALUE=$(mysql -ss -N -e \"SELECT field FROM db.table where fieldwhere = '$2'\")\n\necho $FIELDVALUE\n</code></pre>\n"},{"owner":{"reputation":1,"user_id":3944617,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/cbd42222f23b6c4d4ee1edd3e6b66826?s=128&d=identicon&r=PG","display_name":"tom","link":"http://stackoverflow.com/users/3944617/tom"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773373,"creation_date":1414773373,"answer_id":26679408,"question_id":9558867,"body_markdown":"+----+------------------+----------+--------------------------------+----------+\r\n| ID | Name | Priority | Description | Disabled |\r\n+----+------------------+----------+--------------------------------+----------+\r\n| 1 | Default | 0 | Default System Policy | 0 |\r\n| 2 | Default Outbound | 10 | Default Outbound System Policy | 0 |\r\n| 3 | Default Inbound | 10 | Default Inbound System Policy | 0 |\r\n| 4 | Default Internal | 20 | Default Internal System Policy | 0 |\r\n| 5 | Test | 50 | Test policy | 0 |\r\n| 6 | $u00492 | 100 | SMTP User Policy | 0 |\r\n+----+------------------+----------+--------------------------------+----------+\r\n\r\nThis is my table and i have to select only ID 6 u00492 this use.\r\n\r\nBut above command is not working on this.","link":"http://stackoverflow.com/questions/9558867/how-to-fetch-field-from-mysql-query-result-in-bash/26679408#26679408","body":"<p>+----+------------------+----------+--------------------------------+----------+\n| ID | Name | Priority | Description | Disabled |\n+----+------------------+----------+--------------------------------+----------+\n| 1 | Default | 0 | Default System Policy | 0 |\n| 2 | Default Outbound | 10 | Default Outbound System Policy | 0 |\n| 3 | Default Inbound | 10 | Default Inbound System Policy | 0 |\n| 4 | Default Internal | 20 | Default Internal System Policy | 0 |\n| 5 | Test | 50 | Test policy | 0 |\n| 6 | $u00492 | 100 | SMTP User Policy | 0 |\n+----+------------------+----------+--------------------------------+----------+</p>\n\n<p>This is my table and i have to select only ID 6 u00492 this use.</p>\n\n<p>But above command is not working on this.</p>\n"}],"tags":["mysql","bash"],"owner":{"reputation":3417,"user_id":576831,"user_type":"registered","accept_rate":93,"profile_image":"https://www.gravatar.com/avatar/848e676aff5041064d576a3930ae4aab?s=128&d=identicon&r=PG","display_name":"Nayish","link":"http://stackoverflow.com/users/576831/nayish"},"comment_count":0,"is_answered":true,"view_count":21735,"accepted_answer_id":9558954,"answer_count":4,"score":19,"last_activity_date":1414773373,"creation_date":1330895621,"last_edit_date":1330896234,"question_id":9558867,"body_markdown":"I would like to get only the value of a MySQL query result in a bash script. For example the running the following command:\r\n\r\n mysql -uroot -ppwd -e "SELECT id FROM nagios.host WHERE name='$host'"\r\n\r\nreturns:\r\n\r\n +----+\r\n | id |\r\n +----+\r\n | 0 |\r\n +----+\r\nHow can I fetch the value returned in my bash script?","link":"http://stackoverflow.com/questions/9558867/how-to-fetch-field-from-mysql-query-result-in-bash","title":"How to fetch field from MySQL query result in bash","body":"<p>I would like to get only the value of a MySQL query result in a bash script. For example the running the following command:</p>\n\n<pre><code>mysql -uroot -ppwd -e \"SELECT id FROM nagios.host WHERE name='$host'\"\n</code></pre>\n\n<p>returns:</p>\n\n<pre><code>+----+\n| id |\n+----+\n| 0 |\n+----+\n</code></pre>\n\n<p>How can I fetch the value returned in my bash script?</p>\n"},{"tags":["asp.net","debugging","syntax-error"],"owner":{"reputation":38,"user_id":3783852,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b157fba97ac81fac9e5a77b35cf75e49?s=128&d=identicon&r=PG&f=1","display_name":"user3783852","link":"http://stackoverflow.com/users/3783852/user3783852"},"comments":[{"owner":{"reputation":991,"user_id":638087,"user_type":"registered","accept_rate":72,"profile_image":"https://www.gravatar.com/avatar/c9f31759c969f675b0ab91990c009c12?s=128&d=identicon&r=PG","display_name":"trnelson","link":"http://stackoverflow.com/users/638087/trnelson"},"edited":false,"score":0,"creation_date":1414728056,"post_id":26643396,"comment_id":41936049},{"owner":{"reputation":38,"user_id":3783852,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b157fba97ac81fac9e5a77b35cf75e49?s=128&d=identicon&r=PG&f=1","display_name":"user3783852","link":"http://stackoverflow.com/users/3783852/user3783852"},"reply_to_user":{"reputation":991,"user_id":638087,"user_type":"registered","accept_rate":72,"profile_image":"https://www.gravatar.com/avatar/c9f31759c969f675b0ab91990c009c12?s=128&d=identicon&r=PG","display_name":"trnelson","link":"http://stackoverflow.com/users/638087/trnelson"},"edited":false,"score":0,"creation_date":1414764977,"post_id":26643396,"comment_id":41952562},{"owner":{"reputation":991,"user_id":638087,"user_type":"registered","accept_rate":72,"profile_image":"https://www.gravatar.com/avatar/c9f31759c969f675b0ab91990c009c12?s=128&d=identicon&r=PG","display_name":"trnelson","link":"http://stackoverflow.com/users/638087/trnelson"},"edited":false,"score":0,"creation_date":1414768666,"post_id":26643396,"comment_id":41954898},{"owner":{"reputation":38,"user_id":3783852,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b157fba97ac81fac9e5a77b35cf75e49?s=128&d=identicon&r=PG&f=1","display_name":"user3783852","link":"http://stackoverflow.com/users/3783852/user3783852"},"reply_to_user":{"reputation":991,"user_id":638087,"user_type":"registered","accept_rate":72,"profile_image":"https://www.gravatar.com/avatar/c9f31759c969f675b0ab91990c009c12?s=128&d=identicon&r=PG","display_name":"trnelson","link":"http://stackoverflow.com/users/638087/trnelson"},"edited":false,"score":0,"creation_date":1414770063,"post_id":26643396,"comment_id":41955779},{"owner":{"reputation":16599,"user_id":1127114,"user_type":"registered","accept_rate":80,"profile_image":"https://www.gravatar.com/avatar/bb1b2345f4c7b696d7c0376d273d01b2?s=128&d=identicon&r=PG","display_name":"Michael Liu","link":"http://stackoverflow.com/users/1127114/michael-liu"},"edited":false,"score":0,"creation_date":1414772904,"post_id":26643396,"comment_id":41957454},{"owner":{"reputation":38,"user_id":3783852,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b157fba97ac81fac9e5a77b35cf75e49?s=128&d=identicon&r=PG&f=1","display_name":"user3783852","link":"http://stackoverflow.com/users/3783852/user3783852"},"edited":false,"score":0,"creation_date":1414773226,"post_id":26643396,"comment_id":41957614}],"comment_count":6,"is_answered":false,"view_count":41,"answer_count":0,"score":3,"last_activity_date":1414773372,"creation_date":1414631395,"last_edit_date":1414773372,"question_id":26643396,"body_markdown":"I really desperately need your help because I got very unusual problem with my programs:\r\n\r\n 1. I am receiving this error when I am trying to debug my ASP.NET or MVC Application on local IIS Server 7.5:\r\n"Unable to start debugging on the web server. The debug request could not be processed by the server due to invalid syntax. "\r\n\r\n ![enter image description here][1]\r\n\r\n 2. I tried literally every solution I could find in google until this day. I spent 12 hours trying to figure this out. Without luck.\r\n 3. Error happens only with this address: http:// localhost/AspDemo not with this one: https:// localhost/AspDemo. Basically, I can debug like always if I put https instead of http.\r\n\r\n 4. https is disabled on my local IIS server :), I mean it is set to ignore.\r\n\r\n 5. Moreover I CAN open my sites with using BOTH protocols in IIS Control Panel\r\n\r\n 6. If I disable ASP.NET Debugger in Properties of my App in Visual Studio, Application runs fine.\r\n 7. This is the error from the httperr log:\r\n\r\n **2014-10-30 00:23:46 ::1%0 2977 ::1%0 80 - - - 400 - Verb -**\r\n\r\n 8. I am not sure where exactly, but in some other log I saw reference to something like this: **Error 400 "Bad Request - Invalid Verb"**\r\n 9. A week ago ALL applications I got problems with were working perfectly with asp.net debugger from visual studio, I had no idea what happened.\r\n\r\n 10. I suspect some update. Because updates lately messed with my custom bootloader as well.\r\n\r\n 11. When I enable tracing - log is empty with http\r\n\r\n 12. Fiddler log is empty as well, maybe there is some config I can use in Fiddler to produce some more logs? (It logs of course with modified machine.config when I use https)\r\n\r\nWould be eternally grateful for your help, if you need some more logs, please don't hestitate to ask.\r\n\r\nI would like to mention as well that yes, I saw similar posts on this site, but none of them described problem this similar to mine.\r\n\r\n/edit\r\n\r\nFrom what I was able to observe, error happens BEFORE debugger access machine.config file, can you guys tell me how to catch errors in that moment?\r\n\r\n\r\n**==== /edit 2 ====**\r\n\r\n\r\nAnyone? No one knows the answer?\r\nRecently I was able to find the complete error message in: C:\\Users\\<UserName>\\AppData\\Local\\Temp\\Visual Studio Web Debugger.log\r\n\r\n http://localhost/MVCDemo/debugattach.aspx\r\n\r\n Status code=400 (Bad Request)\r\n Protocol version=1.1\r\n Cached=False\r\n Connection=close\r\n Content-Length=326\r\n Content-Type=text/html; charset=us-ascii\r\n Date=Fri, 31 Oct 2014 03:44:14 GMT\r\n Server=Microsoft-HTTPAPI/2.0\r\n\r\n <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">\r\n <HTML><HEAD><TITLE>Bad Request</TITLE>\r\n <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>\r\n <BODY><h2>Bad Request - Invalid Verb</h2>\r\n <hr><p>HTTP Error 400. The request verb is invalid.</p>\r\n </BODY></HTML>\r\n\r\nIn proccess monitor, I found this one as well:\r\n\r\n <event>\r\n <ProcessIndex>1339</ProcessIndex>\r\n <Time_of_Day>04:40:33,3661553</Time_of_Day>\r\n <Process_Name>devenv.exe</Process_Name>\r\n <PID>10768</PID>\r\n <Operation>CreateFile</Operation>\r\n <Path>C:\\Users\\<UserName>\\AppData\\Roaming\\Microsoft\\VisualStudio\\12.0\\Debugger\\StepIntoFilterData.ini</Path>\r\n <Result>PATH NOT FOUND</Result>\r\n <Detail>Desired Access: Read Data/List Directory, Read Attributes, Synchronize, Disposition: Open, Options: Sequential Access, Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, Delete, AllocationSize: n/a</Detail>\r\n </event>\r\n\r\nI really, really need help with this.\r\n\r\n\r\n**=== /edit 3 ===**\r\n\r\nSecond error is not relevant, I just checked and it is present with https as well (C:\\Users\\<UserName>\\AppData\\Roaming\\Microsoft\\VisualStudio\\12.0\\Debugger\\StepIntoFilterData.in), and debugging as https localhost works perfectly.\r\n\r\n**=== /edit 4 ===**\r\n\r\nHere are Process Monitor logs captured during Visual Studio Debugging HTTP (not working) and HTTPS (working)\r\n\r\n(Test performed on random MVC Tutorial)\r\n\r\nUse CTRL+F and Look for "Visual Studio Web Debugger.log" in logs to get the idea when it is happening. In https log is good, in http log returns Invalid Verb error mentioned before.\r\n\r\n - HTTP (not working)::\r\n https://www.dropbox.com/s/7b26ybogtyqlico/LogFile%20HTTP%20NOT%20Working.CSV?dl=0\r\n - HTTPS (working):\r\n https://www.dropbox.com/s/ggsj57v97ky90e6/LogFile%20HTTPS%20Working.CSV?dl=0\r\n\r\n**I might be wrong, but I think the key here is that only HTTP doesn't work and only with VS Debugger, everything else is just fine.**\r\n\r\n [1]: http://i.stack.imgur.com/qSluD.png","link":"http://stackoverflow.com/questions/26643396/asp-net-debugger-gives-errors-with-http-while-working-with-https","title":"ASP.NET debugger gives errors with http, while working with https","body":"<p>I really desperately need your help because I got very unusual problem with my programs:</p>\n\n<ol>\n<li><p>I am receiving this error when I am trying to debug my ASP.NET or MVC Application on local IIS Server 7.5:\n\"Unable to start debugging on the web server. The debug request could not be processed by the server due to invalid syntax. \"</p>\n\n<p><img src=\"http://i.stack.imgur.com/qSluD.png\" alt=\"enter image description here\"></p></li>\n<li><p>I tried literally every solution I could find in google until this day. I spent 12 hours trying to figure this out. Without luck.</p></li>\n<li><p>Error happens only with this address: http:// localhost/AspDemo not with this one: https:// localhost/AspDemo. Basically, I can debug like always if I put https instead of http.</p></li>\n<li><p>https is disabled on my local IIS server :), I mean it is set to ignore.</p></li>\n<li><p>Moreover I CAN open my sites with using BOTH protocols in IIS Control Panel</p></li>\n<li><p>If I disable ASP.NET Debugger in Properties of my App in Visual Studio, Application runs fine.</p></li>\n<li><p>This is the error from the httperr log:</p>\n\n<p><strong>2014-10-30 00:23:46 ::1%0 2977 ::1%0 80 - - - 400 - Verb -</strong></p></li>\n<li><p>I am not sure where exactly, but in some other log I saw reference to something like this: <strong>Error 400 \"Bad Request - Invalid Verb\"</strong></p></li>\n<li><p>A week ago ALL applications I got problems with were working perfectly with asp.net debugger from visual studio, I had no idea what happened.</p></li>\n<li><p>I suspect some update. Because updates lately messed with my custom bootloader as well.</p></li>\n<li><p>When I enable tracing - log is empty with http</p></li>\n<li><p>Fiddler log is empty as well, maybe there is some config I can use in Fiddler to produce some more logs? (It logs of course with modified machine.config when I use https)</p></li>\n</ol>\n\n<p>Would be eternally grateful for your help, if you need some more logs, please don't hestitate to ask.</p>\n\n<p>I would like to mention as well that yes, I saw similar posts on this site, but none of them described problem this similar to mine.</p>\n\n<p>/edit</p>\n\n<p>From what I was able to observe, error happens BEFORE debugger access machine.config file, can you guys tell me how to catch errors in that moment?</p>\n\n<p><strong>==== /edit 2 ====</strong></p>\n\n<p>Anyone? No one knows the answer?\nRecently I was able to find the complete error message in: C:\\Users\\\\AppData\\Local\\Temp\\Visual Studio Web Debugger.log</p>\n\n<pre><code>http://localhost/MVCDemo/debugattach.aspx\n\nStatus code=400 (Bad Request)\nProtocol version=1.1\nCached=False\nConnection=close\nContent-Length=326\nContent-Type=text/html; charset=us-ascii\nDate=Fri, 31 Oct 2014 03:44:14 GMT\nServer=Microsoft-HTTPAPI/2.0\n\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\"http://www.w3.org/TR/html4/strict.dtd\">\n<HTML><HEAD><TITLE>Bad Request</TITLE>\n<META HTTP-EQUIV=\"Content-Type\" Content=\"text/html; charset=us-ascii\"></HEAD>\n<BODY><h2>Bad Request - Invalid Verb</h2>\n<hr><p>HTTP Error 400. The request verb is invalid.</p>\n</BODY></HTML>\n</code></pre>\n\n<p>In proccess monitor, I found this one as well:</p>\n\n<pre><code><event>\n<ProcessIndex>1339</ProcessIndex>\n<Time_of_Day>04:40:33,3661553</Time_of_Day>\n<Process_Name>devenv.exe</Process_Name>\n<PID>10768</PID>\n<Operation>CreateFile</Operation>\n<Path>C:\\Users\\<UserName>\\AppData\\Roaming\\Microsoft\\VisualStudio\\12.0\\Debugger\\StepIntoFilterData.ini</Path>\n<Result>PATH NOT FOUND</Result>\n<Detail>Desired Access: Read Data/List Directory, Read Attributes, Synchronize, Disposition: Open, Options: Sequential Access, Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, Delete, AllocationSize: n/a</Detail>\n</event>\n</code></pre>\n\n<p>I really, really need help with this.</p>\n\n<p><strong>=== /edit 3 ===</strong></p>\n\n<p>Second error is not relevant, I just checked and it is present with https as well (C:\\Users\\\\AppData\\Roaming\\Microsoft\\VisualStudio\\12.0\\Debugger\\StepIntoFilterData.in), and debugging as https localhost works perfectly.</p>\n\n<p><strong>=== /edit 4 ===</strong></p>\n\n<p>Here are Process Monitor logs captured during Visual Studio Debugging HTTP (not working) and HTTPS (working)</p>\n\n<p>(Test performed on random MVC Tutorial)</p>\n\n<p>Use CTRL+F and Look for \"Visual Studio Web Debugger.log\" in logs to get the idea when it is happening. In https log is good, in http log returns Invalid Verb error mentioned before.</p>\n\n<ul>\n<li>HTTP (not working)::\n<a href=\"https://www.dropbox.com/s/7b26ybogtyqlico/LogFile%20HTTP%20NOT%20Working.CSV?dl=0\" rel=\"nofollow\">https://www.dropbox.com/s/7b26ybogtyqlico/LogFile%20HTTP%20NOT%20Working.CSV?dl=0</a></li>\n<li>HTTPS (working):\n<a href=\"https://www.dropbox.com/s/ggsj57v97ky90e6/LogFile%20HTTPS%20Working.CSV?dl=0\" rel=\"nofollow\">https://www.dropbox.com/s/ggsj57v97ky90e6/LogFile%20HTTPS%20Working.CSV?dl=0</a></li>\n</ul>\n\n<p><strong>I might be wrong, but I think the key here is that only HTTP doesn't work and only with VS Debugger, everything else is just fine.</strong></p>\n"}],"has_more":true,"quota_max":300,"quota_remaining":255} +{"items": + [{"tags":["frames","hooks","focus"],"owner":{"reputation":853,"user_id":2005,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1fd94c0bb560b4445acb97f05b0e9a81?s=128&d=identicon&r=PG","display_name":"rekado","link":"http://emacs.stackexchange.com/users/2005/rekado"},"comments":[{"owner":{"reputation":860,"user_id":10,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1504319df63de7148c39290d4149f150?s=128&d=identicon&r=PG","display_name":"wasamasa","link":"http://emacs.stackexchange.com/users/10/wasamasa"},"edited":false,"score":1,"post_type":"question","creation_date":1414776823,"post_id":2922,"comment_id":4000,"body_markdown":"While this Emacs feature sounds undeniably cool, I think it would be better to leave such a thing to the compositor you're using, `compton` for instance can dim inactive windows.","link":"http://emacs.stackexchange.com/questions/2922/focus-hook-attenuate-colours-when-losing-focus#comment4000_2922","body":"While this Emacs feature sounds undeniably cool, I think it would be better to leave such a thing to the compositor you're using, <code>compton</code> for instance can dim inactive windows."}],"last_editor":{"reputation":853,"user_id":2005,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1fd94c0bb560b4445acb97f05b0e9a81?s=128&d=identicon&r=PG","display_name":"rekado","link":"http://emacs.stackexchange.com/users/2005/rekado"},"comment_count":1,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":false,"view_count":17,"favorite_count":0,"answer_count":0,"score":1,"last_activity_date":1414793447,"creation_date":1414774490,"last_edit_date":1414793447,"question_id":2922,"body_markdown":"How can I use the focus hooks to attenuate all colours in visible buffers when the Emacs frame loses focus?\r\n\r\nI tried using the following code:\r\n\r\n (set-frame-parameter (selected-frame) 'alpha '(100 80))\r\n\r\nTo make the frame become translucent, but it would flicker when I hit <kbd>Ctrl</kbd> (apparently that's because I let GNOME highlight the mouse cursor when I hit <kbd>Ctrl</kbd>).\r\n\r\nMaking the frame transparent isn't what I want anyway. Is it possible to desaturate all colours instead?","link":"http://emacs.stackexchange.com/questions/2922/focus-hook-attenuate-colours-when-losing-focus","title":"Focus-hook: attenuate colours when losing focus","body":"<p>How can I use the focus hooks to attenuate all colours in visible buffers when the Emacs frame loses focus?</p>\n\n<p>I tried using the following code:</p>\n\n<pre><code>(set-frame-parameter (selected-frame) 'alpha '(100 80))\n</code></pre>\n\n<p>To make the frame become translucent, but it would flicker when I hit <kbd>Ctrl</kbd> (apparently that's because I let GNOME highlight the mouse cursor when I hit <kbd>Ctrl</kbd>).</p>\n\n<p>Making the frame transparent isn't what I want anyway. Is it possible to desaturate all colours instead?</p>\n"}, +{"answers":[{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414793088,"creation_date":1414793088,"answer_id":2936,"question_id":2919,"body_markdown":"For your use case, there's still hope though. Since you use `etags`, it can be used with `helm-etags-select`, the Helm built-in command. To use it, simply follow theses steps:\r\n\r\n- First, run the command to generate TAGS file.\r\n- Second, use `find-tag` to feed it to Emacs; if the TAGS file is too large and Emacs asks you to confirm, just accept it. Your whole TAGS file will be loaded in Emacs and there's no more reloading.\r\n- Finally, just execute `helm-etags-select` on any symbol on your Emacs. If there exists only one definition in your project, jump instantly; otherwise, display a Helm buffer for you to choose from.","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable/2936#2936","title":""Making tag completion table" Freezes/Blocks -- how to disable","body":"<p>For your use case, there's still hope though. Since you use <code>etags</code>, it can be used with <code>helm-etags-select</code>, the Helm built-in command. To use it, simply follow theses steps:</p>\n\n<ul>\n<li>First, run the command to generate TAGS file.</li>\n<li>Second, use <code>find-tag</code> to feed it to Emacs; if the TAGS file is too large and Emacs asks you to confirm, just accept it. Your whole TAGS file will be loaded in Emacs and there's no more reloading.</li>\n<li>Finally, just execute <code>helm-etags-select</code> on any symbol on your Emacs. If there exists only one definition in your project, jump instantly; otherwise, display a Helm buffer for you to choose from.</li>\n</ul>\n"}],"tags":["autocomplete","performance","ctags"],"owner":{"reputation":11,"user_id":2265,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a2e453f8f1cfc1ff0d7428c3b66ddc9a?s=128&d=identicon&r=PG","display_name":"cheezy","link":"http://emacs.stackexchange.com/users/2265/cheezy"},"comments":[{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414770948,"post_id":2919,"comment_id":3992,"body_markdown":"For jumping to definition/references, you can use GNU Global with ggtags/helm-gtags. Guarantee to work on large project like Linux kernel without any delay. You may want to look at my [C/C++ guide](http://tuhdo.github.io/c-ide.html). I covered code navigation (jump to definition/references), code completion, compiling and debugging support. I already created a demo configuration for playing with, so you only need to walk through the features without configuring anything.","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment3992_2919","body":"For jumping to definition/references, you can use GNU Global with ggtags/helm-gtags. Guarantee to work on large project like Linux kernel without any delay. You may want to look at my <a href=\"http://tuhdo.github.io/c-ide.html\" rel=\"nofollow\">C/C++ guide</a>. I covered code navigation (jump to definition/references), code completion, compiling and debugging support. I already created a demo configuration for playing with, so you only need to walk through the features without configuring anything."},{"owner":{"reputation":11,"user_id":2265,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a2e453f8f1cfc1ff0d7428c3b66ddc9a?s=128&d=identicon&r=PG","display_name":"cheezy","link":"http://emacs.stackexchange.com/users/2265/cheezy"},"reply_to_user":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414772414,"post_id":2919,"comment_id":3993,"body_markdown":"Your guides were the ones that got me started with emacs (especially w/ C++)! Our build system is very complicated and `#include "..."` can live in various places that are not known until build time. So, ggtags wouldn't be able to generate tags for many of the files. Currently, our build tools allow us to `make etags` to generate emacs compatible tags, but there is no `make ggtags` equivalent. So, I'm stuck with etags for now. Any ideas?","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment3993_2919","body":"Your guides were the ones that got me started with emacs (especially w/ C++)! Our build system is very complicated and <code>#include "..."</code> can live in various places that are not known until build time. So, ggtags wouldn't be able to generate tags for many of the files. Currently, our build tools allow us to <code>make etags</code> to generate emacs compatible tags, but there is no <code>make ggtags</code> equivalent. So, I'm stuck with etags for now. Any ideas?"},{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414773753,"post_id":2919,"comment_id":3995,"body_markdown":"Hmm I see. The situation is more complicated now. You mentioned `ggtags` cannot generate tags, but did you use plain `gtags` on the command line at project root? You should try this and invoke ggtags again. There should not be `make ggtags` because the real command is `gtags`; `ggtags` is just a package name of Emacs that use it. Another option is that you can use [ctags](http://ctags.sourceforge.net/); `ggtags` can also recognize `ctags` tags and it's also fast. You can generate ctags tags when invoking `ggtags-create-tags` and it asks for using `ctags` client.","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment3995_2919","body":"Hmm I see. The situation is more complicated now. You mentioned <code>ggtags</code> cannot generate tags, but did you use plain <code>gtags</code> on the command line at project root? You should try this and invoke ggtags again. There should not be <code>make ggtags</code> because the real command is <code>gtags</code>; <code>ggtags</code> is just a package name of Emacs that use it. Another option is that you can use <a href=\"http://ctags.sourceforge.net/\" rel=\"nofollow\">ctags</a>; <code>ggtags</code> can also recognize <code>ctags</code> tags and it's also fast. You can generate ctags tags when invoking <code>ggtags-create-tags</code> and it asks for using <code>ctags</code> client."},{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414774141,"post_id":2919,"comment_id":3996,"body_markdown":"Anyway, if `gtags` could not know about such details, I don't think the built-in `etags` (comes with Emacs), or `ctags` (I linked above) would be able to do it. I think you only use `ggtags` to create tags at current directory, not project root. Run the command `gtags` at project root, or when `ggtags` asks for where to generate, navigate to project root and you will be fine.","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment3996_2919","body":"Anyway, if <code>gtags</code> could not know about such details, I don't think the built-in <code>etags</code> (comes with Emacs), or <code>ctags</code> (I linked above) would be able to do it. I think you only use <code>ggtags</code> to create tags at current directory, not project root. Run the command <code>gtags</code> at project root, or when <code>ggtags</code> asks for where to generate, navigate to project root and you will be fine."},{"owner":{"reputation":11,"user_id":2265,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a2e453f8f1cfc1ff0d7428c3b66ddc9a?s=128&d=identicon&r=PG","display_name":"cheezy","link":"http://emacs.stackexchange.com/users/2265/cheezy"},"reply_to_user":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414777453,"post_id":2919,"comment_id":4001,"body_markdown":"I verified your statement (all the tag programs can only generate from project root down the tree). `make etags` works because it calls etags once it evaluates where all the `.h` files live.","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment4001_2919","body":"I verified your statement (all the tag programs can only generate from project root down the tree). <code>make etags</code> works because it calls etags once it evaluates where all the <code>.h</code> files live."},{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414777545,"post_id":2919,"comment_id":4002,"body_markdown":"So, it did work? If so, may I turn my comment into answer?","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment4002_2919","body":"So, it did work? If so, may I turn my comment into answer?"},{"owner":{"reputation":11,"user_id":2265,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a2e453f8f1cfc1ff0d7428c3b66ddc9a?s=128&d=identicon&r=PG","display_name":"cheezy","link":"http://emacs.stackexchange.com/users/2265/cheezy"},"reply_to_user":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414778081,"post_id":2919,"comment_id":4003,"body_markdown":"So, if I'm stuck with etags for completeness, do you have any suggestions for 1) Loading the tag file asynchronously 2) Disable autoreload of the tags file?","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment4003_2919","body":"So, if I'm stuck with etags for completeness, do you have any suggestions for 1) Loading the tag file asynchronously 2) Disable autoreload of the tags file?"},{"owner":{"reputation":11,"user_id":2265,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a2e453f8f1cfc1ff0d7428c3b66ddc9a?s=128&d=identicon&r=PG","display_name":"cheezy","link":"http://emacs.stackexchange.com/users/2265/cheezy"},"reply_to_user":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414778190,"post_id":2919,"comment_id":4004,"body_markdown":"Sorry I wasn't very clear. Without involving the `make` command, any tag generation is incomplete. You can turn your comment into an answer, and I can accept it in a day or two to give others a chance to answer","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment4004_2919","body":"Sorry I wasn't very clear. Without involving the <code>make</code> command, any tag generation is incomplete. You can turn your comment into an answer, and I can accept it in a day or two to give others a chance to answer"},{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414779434,"post_id":2919,"comment_id":4005,"body_markdown":"There's one possibility, not sure if you try: since you already have you TAGS file at project root (generated by `etags`), `ggtags` will use that file instead of GTAGS. Did you move the TAGS file (generated by `etags`) elsewhere? Personally, I use `helm-gtags` + GTAGS and always jump instantly, even in the Linux kernel that `etags` generates almost 1 GB. You mention that only some ".h" files available at build time, do you mean those files only generated after the build? Even if it is the case, it's hard to think that any tag program misses those if search recursively.","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment4005_2919","body":"There's one possibility, not sure if you try: since you already have you TAGS file at project root (generated by <code>etags</code>), <code>ggtags</code> will use that file instead of GTAGS. Did you move the TAGS file (generated by <code>etags</code>) elsewhere? Personally, I use <code>helm-gtags</code> + GTAGS and always jump instantly, even in the Linux kernel that <code>etags</code> generates almost 1 GB. You mention that only some ".h" files available at build time, do you mean those files only generated after the build? Even if it is the case, it's hard to think that any tag program misses those if search recursively."},{"owner":{"reputation":11,"user_id":2265,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a2e453f8f1cfc1ff0d7428c3b66ddc9a?s=128&d=identicon&r=PG","display_name":"cheezy","link":"http://emacs.stackexchange.com/users/2265/cheezy"},"reply_to_user":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414790397,"post_id":2919,"comment_id":4009,"body_markdown":"Thanks! I saw your post on helm gtags and this'll work for me for now! Please create an answer so I can accept it :)","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment4009_2919","body":"Thanks! I saw your post on helm gtags and this'll work for me for now! Please create an answer so I can accept it :)"}],"comment_count":10,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":false,"view_count":19,"favorite_count":0,"answer_count":1,"score":2,"last_activity_date":1414793088,"creation_date":1414770468,"question_id":2919,"body_markdown":"**TLDR: I've got a large tags file that loads multiple times per session, making it unusable. Can't find the source of issue or how to disable it -- main goal is to jump to tags, but completion would be nice**\r\n\r\nI recently posted on the emacs subreddit and a user recommended that I join this group because it's also friendly towards newbies.\r\n\r\nI've been using emacs as a C++ IDE, and I'm slowly correcting things that are annoying. I'm essentially using [redguardtoo's emacs.d file][1].\r\n\r\nI have a tag file that is 225MB (1.6M Tags). My intent for the tag is not necessarily completion (using `company`), but more for jumping around source code. I'm working with an unfamiliar code base and often need to see macro or class definitions.\r\n\r\nWhen I start typing, at random times, I'll see a message in the minibuffer\r\n\r\n Making tag completion table for [tag file]...0-100%\r\n\r\nThen, a popup listbox shows up with autocompletion options.\r\n\r\nBecause this tag file is so large, and it doesn't seem like the tag loading is asynchronous, it freezes emacs for around a minute. This also happens multiple times per a session (with the same file, and with other files in the same directory that use the same tag file)!\r\n\r\n---\r\n\r\n**Questions**\r\n\r\n 1. Does anyone know what's initializing the loading of the tag table for completion and how to disable it? I did a grep on my emacs.d directory for "Making tag completion" and found nothing (note, IIRC the loading tags was present regardless of using `company` or `auto-complete`\r\n 2. Completion would be nice, but I'd settle just for the ability to jump to the tag location. Is there a way to get this? \r\n 3. What is the mindset to take when approaching problems like this? I'd like to be able to troubleshoot further on my own next time.\r\n\r\n [1]: https://github.com/redguardtoo/emacs.d\r\n\r\n---\r\n\r\n**Additional info**\r\n\r\nEnabled minor modes (C-h m)\r\n\r\n Enabled minor modes: Abbrev Auto-Composition Auto-Compression\r\n Auto-Encryption Blink-Cursor Column-Number Company Desktop-Save\r\n Display-Time Electric-Indent Electric-Pair Evil Evil-Local\r\n Evil-Matchit Evil-Surround Fic File-Name-Shadow Flyspell-Lazy\r\n Font-Lock Ggtags Global-Auto-Revert Global-Company Global-Eldoc\r\n Global-Evil-Matchit Global-Evil-Surround Global-Font-Lock Global-Linum\r\n Global-Page-Break-Lines Global-Pointback Global-Undo-Tree Helm\r\n Helm-Match-Plugin Helm-Occur-Match-Plugin Line-Number Linum Menu-Bar\r\n Mouse-Wheel Override-Global Pointback Recentf Savehist Shell-Dirtrack\r\n Subword Tooltip Undo-Tree Which-Function Window-Numbering Winner Yas\r\n Yas-Global\r\n\r\n","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable","title":""Making tag completion table" Freezes/Blocks -- how to disable","body":"<p><strong>TLDR: I've got a large tags file that loads multiple times per session, making it unusable. Can't find the source of issue or how to disable it -- main goal is to jump to tags, but completion would be nice</strong></p>\n\n<p>I recently posted on the emacs subreddit and a user recommended that I join this group because it's also friendly towards newbies.</p>\n\n<p>I've been using emacs as a C++ IDE, and I'm slowly correcting things that are annoying. I'm essentially using <a href=\"https://github.com/redguardtoo/emacs.d\" rel=\"nofollow\">redguardtoo's emacs.d file</a>.</p>\n\n<p>I have a tag file that is 225MB (1.6M Tags). My intent for the tag is not necessarily completion (using <code>company</code>), but more for jumping around source code. I'm working with an unfamiliar code base and often need to see macro or class definitions.</p>\n\n<p>When I start typing, at random times, I'll see a message in the minibuffer</p>\n\n<pre><code>Making tag completion table for [tag file]...0-100%\n</code></pre>\n\n<p>Then, a popup listbox shows up with autocompletion options.</p>\n\n<p>Because this tag file is so large, and it doesn't seem like the tag loading is asynchronous, it freezes emacs for around a minute. This also happens multiple times per a session (with the same file, and with other files in the same directory that use the same tag file)!</p>\n\n<hr>\n\n<p><strong>Questions</strong></p>\n\n<ol>\n<li>Does anyone know what's initializing the loading of the tag table for completion and how to disable it? I did a grep on my emacs.d directory for \"Making tag completion\" and found nothing (note, IIRC the loading tags was present regardless of using <code>company</code> or <code>auto-complete</code></li>\n<li>Completion would be nice, but I'd settle just for the ability to jump to the tag location. Is there a way to get this? </li>\n<li>What is the mindset to take when approaching problems like this? I'd like to be able to troubleshoot further on my own next time.</li>\n</ol>\n\n<hr>\n\n<p><strong>Additional info</strong></p>\n\n<p>Enabled minor modes (C-h m)</p>\n\n<pre><code>Enabled minor modes: Abbrev Auto-Composition Auto-Compression\nAuto-Encryption Blink-Cursor Column-Number Company Desktop-Save\nDisplay-Time Electric-Indent Electric-Pair Evil Evil-Local\nEvil-Matchit Evil-Surround Fic File-Name-Shadow Flyspell-Lazy\nFont-Lock Ggtags Global-Auto-Revert Global-Company Global-Eldoc\nGlobal-Evil-Matchit Global-Evil-Surround Global-Font-Lock Global-Linum\nGlobal-Page-Break-Lines Global-Pointback Global-Undo-Tree Helm\nHelm-Match-Plugin Helm-Occur-Match-Plugin Line-Number Linum Menu-Bar\nMouse-Wheel Override-Global Pointback Recentf Savehist Shell-Dirtrack\nSubword Tooltip Undo-Tree Which-Function Window-Numbering Winner Yas\nYas-Global\n</code></pre>\n"} + ,{"tags":["interactive-development"],"owner":{"reputation":512,"user_id":2264,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/9261936847b5a31e15da6e86533d3de3?s=128&d=identicon&r=PG","display_name":"Sean Allred","link":"http://emacs.stackexchange.com/users/2264/sean-allred"},"comment_count":0,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":false,"view_count":5,"favorite_count":0,"answer_count":0,"score":0,"last_activity_date":1414792387,"creation_date":1414792387,"question_id":2935,"body_markdown":"I've accidentally run the following:\r\n\r\n (unintern variable)\r\n\r\nwhere `variable`'s value was `nil`.\r\n\r\nHow do I get `nil` back without restarting Emacs?","link":"http://emacs.stackexchange.com/questions/2935/how-can-i-bring-back-nil","title":"How can I bring back `nil`?","body":"<p>I've accidentally run the following:</p>\n\n<pre><code>(unintern variable)\n</code></pre>\n\n<p>where <code>variable</code>'s value was <code>nil</code>.</p>\n\n<p>How do I get <code>nil</code> back without restarting Emacs?</p>\n"},{"answers":[{"owner":{"reputation":472,"user_id":372,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/cb378ba79d85a04a9277ddc0e4259149?s=128&d=identicon&r=PG","display_name":"purple_arrows","link":"http://emacs.stackexchange.com/users/372/purple-arrows"},"comments":[{"owner":{"reputation":1709,"user_id":93,"user_type":"registered","accept_rate":55,"profile_image":"https://www.gravatar.com/avatar/52ada69db49a5d75240cc0c989c934f4?s=128&d=identicon&r=PG","display_name":"nispio","link":"http://emacs.stackexchange.com/users/93/nispio"},"edited":false,"score":0,"post_type":"answer","creation_date":1413990079,"post_id":2425,"comment_id":3199,"body_markdown":"I am using X, and `-d :0.0` works fine, but for some reason `-d :0.1` gives an error: `Display :0.1 can't be opened`.","link":"http://emacs.stackexchange.com/questions/2417/open-edit-server-files-from-emacsclient-in-a-specific-frame/2425#comment3199_2425","body":"I am using X, and <code>-d :0.0</code> works fine, but for some reason <code>-d :0.1</code> gives an error: <code>Display :0.1 can't be opened</code>."},{"owner":{"reputation":472,"user_id":372,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/cb378ba79d85a04a9277ddc0e4259149?s=128&d=identicon&r=PG","display_name":"purple_arrows","link":"http://emacs.stackexchange.com/users/372/purple-arrows"},"reply_to_user":{"reputation":1709,"user_id":93,"user_type":"registered","accept_rate":55,"profile_image":"https://www.gravatar.com/avatar/52ada69db49a5d75240cc0c989c934f4?s=128&d=identicon&r=PG","display_name":"nispio","link":"http://emacs.stackexchange.com/users/93/nispio"},"edited":false,"score":0,"post_type":"answer","creation_date":1414003353,"post_id":2425,"comment_id":3232,"body_markdown":"Your monitors may be set up as one big screen, as opposed to two separate screens. You can tell if you can drag an (X) window a/k/a (Emacs) frame from one monitor to the other - if that's the case, then this solution won't work for you.","link":"http://emacs.stackexchange.com/questions/2417/open-edit-server-files-from-emacsclient-in-a-specific-frame/2425#comment3232_2425","body":"Your monitors may be set up as one big screen, as opposed to two separate screens. You can tell if you can drag an (X) window a/k/a (Emacs) frame from one monitor to the other - if that's the case, then this solution won't work for you."},{"owner":{"reputation":1709,"user_id":93,"user_type":"registered","accept_rate":55,"profile_image":"https://www.gravatar.com/avatar/52ada69db49a5d75240cc0c989c934f4?s=128&d=identicon&r=PG","display_name":"nispio","link":"http://emacs.stackexchange.com/users/93/nispio"},"edited":false,"score":0,"post_type":"answer","creation_date":1414011499,"post_id":2425,"comment_id":3240,"body_markdown":"You are right. This won't work for me, because my monitors are configured as a single display.","link":"http://emacs.stackexchange.com/questions/2417/open-edit-server-files-from-emacsclient-in-a-specific-frame/2425#comment3240_2425","body":"You are right. This won't work for me, because my monitors are configured as a single display."}],"comment_count":3,"is_accepted":false,"score":2,"last_activity_date":1413954754,"creation_date":1413954754,"answer_id":2425,"question_id":2417,"body_markdown":"If your windowing system is X and your monitors are configured as separate screens, you can pass the appropriate `DISPLAY` value (e.g. `:0.0` or `:0.1`) to emacsclient with the `-d` option. That's kind of a big "if".","link":"http://emacs.stackexchange.com/questions/2417/open-edit-server-files-from-emacsclient-in-a-specific-frame/2425#2425","title":"Open edit-server files from emacsclient in a specific frame","body":"<p>If your windowing system is X and your monitors are configured as separate screens, you can pass the appropriate <code>DISPLAY</code> value (e.g. <code>:0.0</code> or <code>:0.1</code>) to emacsclient with the <code>-d</code> option. That's kind of a big \"if\".</p>\n"},{"owner":{"reputation":1,"user_id":2353,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ef46008cedba3b32fae8586adb16cb8f?s=128&d=identicon&r=PG","display_name":"Jacek","link":"http://emacs.stackexchange.com/users/2353/jacek"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414790834,"creation_date":1414790834,"answer_id":2934,"question_id":2417,"body_markdown":"I have _some_ success with the following command:\r\n\r\n emacsclient --eval "(select-frame (car (frames-on-display-list)))"; sleep 1s; emacsclient -n file.txt\r\n\r\nThe lisp code selects the first frame. To select the second one you should replace car with cadr. But I have not found a way to know which frame is the first ;)\r\n\r\nBests,\r\n\r\nJacek","link":"http://emacs.stackexchange.com/questions/2417/open-edit-server-files-from-emacsclient-in-a-specific-frame/2934#2934","title":"Open edit-server files from emacsclient in a specific frame","body":"<p>I have <em>some</em> success with the following command:</p>\n\n<pre><code>emacsclient --eval \"(select-frame (car (frames-on-display-list)))\"; sleep 1s; emacsclient -n file.txt\n</code></pre>\n\n<p>The lisp code selects the first frame. To select the second one you should replace car with cadr. But I have not found a way to know which frame is the first ;)</p>\n\n<p>Bests,</p>\n\n<p>Jacek</p>\n"}],"tags":["frames","emacsclient"],"owner":{"reputation":1709,"user_id":93,"user_type":"registered","accept_rate":55,"profile_image":"https://www.gravatar.com/avatar/52ada69db49a5d75240cc0c989c934f4?s=128&d=identicon&r=PG","display_name":"nispio","link":"http://emacs.stackexchange.com/users/93/nispio"},"comments":[{"owner":{"reputation":472,"user_id":372,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/cb378ba79d85a04a9277ddc0e4259149?s=128&d=identicon&r=PG","display_name":"purple_arrows","link":"http://emacs.stackexchange.com/users/372/purple-arrows"},"edited":false,"score":0,"post_type":"question","creation_date":1413954069,"post_id":2417,"comment_id":3171,"body_markdown":"Which operating system are you running? Answers may vary if your window system is X, Windows, Mac OS.","link":"http://emacs.stackexchange.com/questions/2417/open-edit-server-files-from-emacsclient-in-a-specific-frame#comment3171_2417","body":"Which operating system are you running? Answers may vary if your window system is X, Windows, Mac OS."},{"owner":{"reputation":1709,"user_id":93,"user_type":"registered","accept_rate":55,"profile_image":"https://www.gravatar.com/avatar/52ada69db49a5d75240cc0c989c934f4?s=128&d=identicon&r=PG","display_name":"nispio","link":"http://emacs.stackexchange.com/users/93/nispio"},"reply_to_user":{"reputation":472,"user_id":372,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/cb378ba79d85a04a9277ddc0e4259149?s=128&d=identicon&r=PG","display_name":"purple_arrows","link":"http://emacs.stackexchange.com/users/372/purple-arrows"},"edited":false,"score":0,"post_type":"question","creation_date":1413990313,"post_id":2417,"comment_id":3200,"body_markdown":"@purple_arrows Typically I am on Linux, but I also use Emacs on Mac and Windows. Also, I would like to be able to send the file to a specific **frame** if possible, not just a specific display.","link":"http://emacs.stackexchange.com/questions/2417/open-edit-server-files-from-emacsclient-in-a-specific-frame#comment3200_2417","body":"@purple_arrows Typically I am on Linux, but I also use Emacs on Mac and Windows. Also, I would like to be able to send the file to a specific <b>frame</b> if possible, not just a specific display."},{"owner":{"reputation":472,"user_id":372,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/cb378ba79d85a04a9277ddc0e4259149?s=128&d=identicon&r=PG","display_name":"purple_arrows","link":"http://emacs.stackexchange.com/users/372/purple-arrows"},"edited":false,"score":0,"post_type":"question","creation_date":1414003752,"post_id":2417,"comment_id":3233,"body_markdown":"It'll take me a while to get back to an answer that (fingers crossed) works cross platforms. `server-select-display` does the work of selecting the frame to use, and unfortunately it doesn't offer any hooks to customize.","link":"http://emacs.stackexchange.com/questions/2417/open-edit-server-files-from-emacsclient-in-a-specific-frame#comment3233_2417","body":"It'll take me a while to get back to an answer that (fingers crossed) works cross platforms. <code>server-select-display</code> does the work of selecting the frame to use, and unfortunately it doesn't offer any hooks to customize."}],"last_editor":{"reputation":1709,"user_id":93,"user_type":"registered","accept_rate":55,"profile_image":"https://www.gravatar.com/avatar/52ada69db49a5d75240cc0c989c934f4?s=128&d=identicon&r=PG","display_name":"nispio","link":"http://emacs.stackexchange.com/users/93/nispio"},"comment_count":3,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":43,"favorite_count":2,"answer_count":2,"score":4,"last_activity_date":1414790834,"creation_date":1413927107,"last_edit_date":1413990607,"question_id":2417,"body_markdown":"Is there a way to designate a specific frame in which files opened with `emacsclient` will appear?\r\n\r\nI have one monitor that is dedicated to a fullscreen Emacs frame. I do most of my editing in that monitor, but from time to time I will open a second frame on another monitor temporarily. I want to ensure that every time I open a file using `emacsclient`, it gets sent to my fullscreen frame and doesn't end up on any other frames that might be open.\r\n\r\n**Edit:**\r\n\r\nThe ideal workflow would be that my **initial** emacs frame gets tagged as the recipient of all `emacsclient` requests, and the rest is automatic. I always use the initial frame as my primary emacs frame, and other frames come and go as needed.","link":"http://emacs.stackexchange.com/questions/2417/open-edit-server-files-from-emacsclient-in-a-specific-frame","title":"Open edit-server files from emacsclient in a specific frame","body":"<p>Is there a way to designate a specific frame in which files opened with <code>emacsclient</code> will appear?</p>\n\n<p>I have one monitor that is dedicated to a fullscreen Emacs frame. I do most of my editing in that monitor, but from time to time I will open a second frame on another monitor temporarily. I want to ensure that every time I open a file using <code>emacsclient</code>, it gets sent to my fullscreen frame and doesn't end up on any other frames that might be open.</p>\n\n<p><strong>Edit:</strong></p>\n\n<p>The ideal workflow would be that my <strong>initial</strong> emacs frame gets tagged as the recipient of all <code>emacsclient</code> requests, and the rest is automatic. I always use the initial frame as my primary emacs frame, and other frames come and go as needed.</p>\n"},{"tags":["compression","url"],"owner":{"reputation":512,"user_id":2264,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/9261936847b5a31e15da6e86533d3de3?s=128&d=identicon&r=PG","display_name":"Sean Allred","link":"http://emacs.stackexchange.com/users/2264/sean-allred"},"comment_count":0,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":false,"view_count":6,"favorite_count":0,"answer_count":0,"score":1,"last_activity_date":1414789578,"creation_date":1414789578,"question_id":2931,"body_markdown":"I know that I can use the [`file`][1] command to determine this, but I'd like a cross-platform solution using elisp only (or as few subprocesses as possible). I have the compressed data in a variable called `response`; you can use the following shell command to get a sample of the data I'm trying to profile:\r\n\r\n curl --silent "http://api.stackexchange.com/2.2/filter/create?filter=default&exclude=user.profile_image;shallow_user.profile_image"\r\n\r\nPiping the above through `gunzip` will give a readable result. The problem is that my mechanism for retrieving the information has different behavior when it is run locally and when it is run on Travis.\r\n\r\nUnfortunately, the `Content-Encoding` header *lies*.\r\n\r\n [1]: http://unix.stackexchange.com/a/63920\r\n [2]: https://github.com/vermiculus/stack-mode/blob/master/tests.el#L16","link":"http://emacs.stackexchange.com/questions/2931/how-can-i-determine-if-a-file-is-compressed-from-elisp","title":"How can I determine if a file is compressed from Elisp?","body":"<p>I know that I can use the <a href=\"http://unix.stackexchange.com/a/63920\"><code>file</code></a> command to determine this, but I'd like a cross-platform solution using elisp only (or as few subprocesses as possible). I have the compressed data in a variable called <code>response</code>; you can use the following shell command to get a sample of the data I'm trying to profile:</p>\n\n<pre><code>curl --silent \"http://api.stackexchange.com/2.2/filter/create?filter=default&exclude=user.profile_image;shallow_user.profile_image\"\n</code></pre>\n\n<p>Piping the above through <code>gunzip</code> will give a readable result. The problem is that my mechanism for retrieving the information has different behavior when it is run locally and when it is run on Travis.</p>\n\n<p>Unfortunately, the <code>Content-Encoding</code> header <em>lies</em>.</p>\n"},{"answers":[{"owner":{"reputation":486,"user_id":1974,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/bd580f3842d43ba9dd42aff4914a38d3?s=128&d=identicon&r=PG&f=1","display_name":"rasmus","link":"http://emacs.stackexchange.com/users/1974/rasmus"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414784968,"creation_date":1414784968,"answer_id":2926,"question_id":2920,"body_markdown":"You clearly did not [consult the manual][1] before posting this. Upon reading the manual, you will not only know that you could have gotten what you desired result by using the header `#+BEGIN_SRC maxima :results value verbatim` or `#+BEGIN_SRC maxima :results value code` you will also know that `raw` means raw Org code.\r\n\r\n [1]: http://orgmode.org/manual/results.html#results","link":"http://emacs.stackexchange.com/questions/2920/babel-doesnt-wrap-results-in-verbatim/2926#2926","title":"Babel doesn't wrap results in verbatim","body":"<p>You clearly did not <a href=\"http://orgmode.org/manual/results.html#results\" rel=\"nofollow\">consult the manual</a> before posting this. Upon reading the manual, you will not only know that you could have gotten what you desired result by using the header <code>#+BEGIN_SRC maxima :results value verbatim</code> or <code>#+BEGIN_SRC maxima :results value code</code> you will also know that <code>raw</code> means raw Org code.</p>\n"}],"tags":["org-mode","org-export","org-babel"],"owner":{"reputation":255,"user_id":563,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/e5ab5db401198485d4569199f9994a7d?s=128&d=identicon&r=PG","display_name":"wvxvw","link":"http://emacs.stackexchange.com/users/563/wvxvw"},"last_editor":{"reputation":255,"user_id":563,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/e5ab5db401198485d4569199f9994a7d?s=128&d=identicon&r=PG","display_name":"wvxvw","link":"http://emacs.stackexchange.com/users/563/wvxvw"},"comment_count":0,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":false,"view_count":15,"favorite_count":0,"answer_count":1,"score":0,"last_activity_date":1414784968,"creation_date":1414770503,"last_edit_date":1414770962,"question_id":2920,"body_markdown":"Here's an example:\r\n\r\n #+NAME: sys5\r\n #+HEADER: :exports both\r\n #+BEGIN_SRC maxima :results raw\r\n programmode: false;\r\n solution: triangularize(coefmatrix(\r\n [ -3*x - 11*y + 7*z = 0,\r\n 2*x + 6*y - 2*z = 0,\r\n x + 2*y + z = 0],\r\n [x, y, z]));\r\n print(solution);\r\n #+END_SRC\r\n \r\n # (1)\r\n #+RESULTS: sys5\r\n : [ - 3 - 11 7 ]\r\n : [ ]\r\n : [ 0 4 - 8 ] \r\n : [ ]\r\n : [ 0 0 0 ]\r\n # (2)\r\n #+BEGIN_EXAMPLE\r\n [ - 3 - 11 7 ]\r\n [ ]\r\n [ 0 4 - 8 ] \r\n [ ]\r\n [ 0 0 0 ]\r\n #+END_EXAMPLE\r\n \r\n Triangulated matrix of the above solution doesn't have pivot in the third\r\n column, thus it doesn't have a unique solution.\r\n\r\n(1) is printed like so: `[-3 -11 7] [] [0 4 -8] [] [0 0 0]`, but (2) prints properly, i.e. every line on the separate line. Interestingly, if there's some text after the `#+RESULTS:`, then export doesn't add `=` around the result, otherwise, it does.\r\n\r\nIs there anything special about `[]` in results?","link":"http://emacs.stackexchange.com/questions/2920/babel-doesnt-wrap-results-in-verbatim","title":"Babel doesn't wrap results in verbatim","body":"<p>Here's an example:</p>\n\n<pre><code> #+NAME: sys5\n #+HEADER: :exports both\n #+BEGIN_SRC maxima :results raw\n programmode: false;\n solution: triangularize(coefmatrix(\n [ -3*x - 11*y + 7*z = 0,\n 2*x + 6*y - 2*z = 0,\n x + 2*y + z = 0],\n [x, y, z]));\n print(solution);\n #+END_SRC\n\n # (1)\n #+RESULTS: sys5\n : [ - 3 - 11 7 ]\n : [ ]\n : [ 0 4 - 8 ] \n : [ ]\n : [ 0 0 0 ]\n # (2)\n #+BEGIN_EXAMPLE\n [ - 3 - 11 7 ]\n [ ]\n [ 0 4 - 8 ] \n [ ]\n [ 0 0 0 ]\n #+END_EXAMPLE\n\n Triangulated matrix of the above solution doesn't have pivot in the third\n column, thus it doesn't have a unique solution.\n</code></pre>\n\n<p>(1) is printed like so: <code>[-3 -11 7] [] [0 4 -8] [] [0 0 0]</code>, but (2) prints properly, i.e. every line on the separate line. Interestingly, if there's some text after the <code>#+RESULTS:</code>, then export doesn't add <code>=</code> around the result, otherwise, it does.</p>\n\n<p>Is there anything special about <code>[]</code> in results?</p>\n"},{"answers":[{"owner":{"reputation":3478,"user_id":105,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/32a8e553d85d193ee5ae1533ce6ec158?s=128&d=identicon&r=PG&f=1","display_name":"Drew","link":"http://emacs.stackexchange.com/users/105/drew"},"comments":[{"owner":{"reputation":2720,"user_id":25,"user_type":"registered","profile_image":"http://i.stack.imgur.com/O5VNX.jpg?s=128&g=1","display_name":"Gilles","link":"http://emacs.stackexchange.com/users/25/gilles"},"edited":false,"score":0,"post_type":"answer","creation_date":1413661410,"post_id":2325,"comment_id":3040,"body_markdown":"Given your analysis, I guess making `face-remapping-alist` [permanent](https://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Buffer_002dLocal.html#index-permanent-local-variable-679) would work? For the backquotes in code markup, see [this answer](http://meta.emacs.stackexchange.com/posts/31/revisions).","link":"http://emacs.stackexchange.com/questions/2323/can-i-change-the-background-color-of-the-inactive-minibuffer/2325#comment3040_2325","body":"Given your analysis, I guess making <code>face-remapping-alist</code> <a href=\"https://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Buffer_002dLocal.html#index-permanent-local-variable-679\" rel=\"nofollow\">permanent</a> would work? For the backquotes in code markup, see <a href=\"http://meta.emacs.stackexchange.com/posts/31/revisions\">this answer</a>."},{"owner":{"reputation":3478,"user_id":105,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/32a8e553d85d193ee5ae1533ce6ec158?s=128&d=identicon&r=PG&f=1","display_name":"Drew","link":"http://emacs.stackexchange.com/users/105/drew"},"reply_to_user":{"reputation":2720,"user_id":25,"user_type":"registered","profile_image":"http://i.stack.imgur.com/O5VNX.jpg?s=128&g=1","display_name":"Gilles","link":"http://emacs.stackexchange.com/users/25/gilles"},"edited":false,"score":0,"post_type":"answer","creation_date":1413673313,"post_id":2325,"comment_id":3041,"body_markdown":"@Gilles: Yes, I read that answer the first time. Feel free to edit my answer, to put that string better backticks (so that it appears correct. ;-) I wasn't successful in doing that.","link":"http://emacs.stackexchange.com/questions/2323/can-i-change-the-background-color-of-the-inactive-minibuffer/2325#comment3041_2325","body":"@Gilles: Yes, I read that answer the first time. Feel free to edit my answer, to put that string better backticks (so that it appears correct. ;-) I wasn't successful in doing that."}],"last_editor":{"reputation":3478,"user_id":105,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/32a8e553d85d193ee5ae1533ce6ec158?s=128&d=identicon&r=PG&f=1","display_name":"Drew","link":"http://emacs.stackexchange.com/users/105/drew"},"comment_count":2,"is_accepted":false,"score":5,"last_activity_date":1413752373,"last_edit_date":1413752373,"creation_date":1413647017,"answer_id":2325,"question_id":2323,"body_markdown":"`minibuffer-setup-hook` is used only when the minibuffer is set up, i.e., activated, not when it is deactivated. \r\n\r\n`minibuffer-exit-hook` takes effect when the minibuffer is exited. There is also `minibuffer-inactive-mode-hook`. \r\n\r\nBut although those do initiate the color change (as shown by adding `(debug)` at the beginning of the hook function, and then stepping through the debugger with `d`), it seems that `kill-local-variables` removes the added color at some point. I don't have time now to check further, but perhaps you can, or perhaps someone else has a quick solution. Sorry for providing only incomplete info.\r\n\r\nGotta go now - but quickly, I'm guessing that maybe you don't need to fiddle with hooks at all, and you can just do the face remapping for all buffers with names matching ``\\` \\*Minibuf-[0-9]+\\*\\'``.\r\n\r\n---\r\n\r\nFWIW, I use a [separate minibuffer frame](http://www.emacswiki.org/emacs-en/download/oneonone.el), and I put this on `minibuffer-exit-hook` to color the frame background:\r\n\r\n (defun 1on1-color-minibuffer-frame-on-exit ()\r\n "Change background of minibuffer frame to reflect the minibuffer depth.\r\n Use this when reducing the minibuffer recursion depth."\r\n (when 1on1-minibuffer-frame\r\n (save-window-excursion\r\n (select-frame 1on1-minibuffer-frame)\r\n (cond ((= (minibuffer-depth) 2)\r\n (set-background-color 1on1-active-minibuffer-frame-background))\r\n ((< (minibuffer-depth) 2)\r\n (set-background-color 1on1-inactive-minibuffer-frame-background))\r\n (t\r\n (set-background-color (hexrgb-increment-hue ; Change bg hue slightly.\r\n (frame-parameter nil 'background-color)\r\n 1on1-color-minibuffer-frame-on-exit-increment)))))))","link":"http://emacs.stackexchange.com/questions/2323/can-i-change-the-background-color-of-the-inactive-minibuffer/2325#2325","title":"Can I change the background color of the inactive minibuffer?","body":"<p><code>minibuffer-setup-hook</code> is used only when the minibuffer is set up, i.e., activated, not when it is deactivated. </p>\n\n<p><code>minibuffer-exit-hook</code> takes effect when the minibuffer is exited. There is also <code>minibuffer-inactive-mode-hook</code>. </p>\n\n<p>But although those do initiate the color change (as shown by adding <code>(debug)</code> at the beginning of the hook function, and then stepping through the debugger with <code>d</code>), it seems that <code>kill-local-variables</code> removes the added color at some point. I don't have time now to check further, but perhaps you can, or perhaps someone else has a quick solution. Sorry for providing only incomplete info.</p>\n\n<p>Gotta go now - but quickly, I'm guessing that maybe you don't need to fiddle with hooks at all, and you can just do the face remapping for all buffers with names matching <code>\\` \\*Minibuf-[0-9]+\\*\\'</code>.</p>\n\n<hr>\n\n<p>FWIW, I use a <a href=\"http://www.emacswiki.org/emacs-en/download/oneonone.el\" rel=\"nofollow\">separate minibuffer frame</a>, and I put this on <code>minibuffer-exit-hook</code> to color the frame background:</p>\n\n<pre><code>(defun 1on1-color-minibuffer-frame-on-exit ()\n \"Change background of minibuffer frame to reflect the minibuffer depth.\nUse this when reducing the minibuffer recursion depth.\"\n (when 1on1-minibuffer-frame\n (save-window-excursion\n (select-frame 1on1-minibuffer-frame)\n (cond ((= (minibuffer-depth) 2)\n (set-background-color 1on1-active-minibuffer-frame-background))\n ((< (minibuffer-depth) 2)\n (set-background-color 1on1-inactive-minibuffer-frame-background))\n (t\n (set-background-color (hexrgb-increment-hue ; Change bg hue slightly.\n (frame-parameter nil 'background-color)\n 1on1-color-minibuffer-frame-on-exit-increment)))))))\n</code></pre>\n"},{"owner":{"reputation":631,"user_id":1979,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6d7d7689f9562293f6106353a6b1a905?s=128&d=identicon&r=PG","display_name":"Stefan","link":"http://emacs.stackexchange.com/users/1979/stefan"},"comment_count":0,"is_accepted":false,"score":1,"last_activity_date":1414784512,"creation_date":1414784512,"answer_id":2925,"question_id":2323,"body_markdown":"You might try:\r\n\r\n (dolist (buf '(" *Echo Area 0*" " *Echo Area 1*"))\r\n (with-current-buffer (get-buffer buf)\r\n (make-local-variable 'face-remapping-alist)\r\n (add-to-list 'face-remapping-alist '(default (:background "green")))))\r\n","link":"http://emacs.stackexchange.com/questions/2323/can-i-change-the-background-color-of-the-inactive-minibuffer/2925#2925","title":"Can I change the background color of the inactive minibuffer?","body":"<p>You might try:</p>\n\n<pre><code>(dolist (buf '(\" *Echo Area 0*\" \" *Echo Area 1*\"))\n (with-current-buffer (get-buffer buf)\n (make-local-variable 'face-remapping-alist)\n (add-to-list 'face-remapping-alist '(default (:background \"green\")))))\n</code></pre>\n"}],"tags":["customize","faces","minibuffer"],"owner":{"reputation":171,"user_id":600,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/100e9ef8e9f5d6baa08667b4188d64eb?s=128&d=identicon&r=PG","display_name":"mcb","link":"http://emacs.stackexchange.com/users/600/mcb"},"comments":[{"owner":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":0,"post_type":"question","creation_date":1413635932,"post_id":2323,"comment_id":3024,"body_markdown":"I believe that's also called the echo area.","link":"http://emacs.stackexchange.com/questions/2323/can-i-change-the-background-color-of-the-inactive-minibuffer#comment3024_2323","body":"I believe that's also called the echo area."},{"owner":{"reputation":3478,"user_id":105,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/32a8e553d85d193ee5ae1533ce6ec158?s=128&d=identicon&r=PG&f=1","display_name":"Drew","link":"http://emacs.stackexchange.com/users/105/drew"},"reply_to_user":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":1,"post_type":"question","creation_date":1413645757,"post_id":2323,"comment_id":3028,"body_markdown":"@Malabarba: It is *only* called the echo area (when the minibuffer is inactive).","link":"http://emacs.stackexchange.com/questions/2323/can-i-change-the-background-color-of-the-inactive-minibuffer#comment3028_2323","body":"@Malabarba: It is <i>only</i> called the echo area (when the minibuffer is inactive)."}],"last_editor":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"comment_count":2,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":90,"favorite_count":1,"answer_count":2,"score":8,"last_activity_date":1414784512,"creation_date":1413626421,"last_edit_date":1413635904,"question_id":2323,"body_markdown":"![Inactive Minibuffer][1]\r\n\r\nI tried it with the following settings:\r\n\r\n (add-hook 'minibuffer-setup-hook\r\n (lambda ()\r\n (make-local-variable 'face-remapping-alist)\r\n (add-to-list 'face-remapping-alist '(default (:background "green")))))\r\n\r\n (set-face-background 'minibuffer-prompt "blue")\r\n\r\nbut they only affected the active minibuffer:\r\n\r\n![Active Minibuffer][2]\r\n\r\n\r\n [1]: http://i.stack.imgur.com/d7XGr.png\r\n [2]: http://i.stack.imgur.com/kXFi4.png","link":"http://emacs.stackexchange.com/questions/2323/can-i-change-the-background-color-of-the-inactive-minibuffer","title":"Can I change the background color of the inactive minibuffer?","body":"<p><img src=\"http://i.stack.imgur.com/d7XGr.png\" alt=\"Inactive Minibuffer\"></p>\n\n<p>I tried it with the following settings:</p>\n\n<pre><code>(add-hook 'minibuffer-setup-hook\n (lambda ()\n (make-local-variable 'face-remapping-alist)\n (add-to-list 'face-remapping-alist '(default (:background \"green\")))))\n\n(set-face-background 'minibuffer-prompt \"blue\")\n</code></pre>\n\n<p>but they only affected the active minibuffer:</p>\n\n<p><img src=\"http://i.stack.imgur.com/kXFi4.png\" alt=\"Active Minibuffer\"></p>\n"},{"answers":[{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"comments":[{"owner":{"reputation":1709,"user_id":93,"user_type":"registered","accept_rate":55,"profile_image":"https://www.gravatar.com/avatar/52ada69db49a5d75240cc0c989c934f4?s=128&d=identicon&r=PG","display_name":"nispio","link":"http://emacs.stackexchange.com/users/93/nispio"},"edited":false,"score":0,"post_type":"answer","creation_date":1414737627,"post_id":2893,"comment_id":3943,"body_markdown":"I just tried this out, and it seems like it would only be useful in a flat directory structure. As soon as I open a file in `src/` the project root changes to `src/` and I can no longer jump to the files in `inc/`.","link":"http://emacs.stackexchange.com/questions/2891/projectile-project-in-folder-without-write-access/2893#comment3943_2893","body":"I just tried this out, and it seems like it would only be useful in a flat directory structure. As soon as I open a file in <code>src/</code> the project root changes to <code>src/</code> and I can no longer jump to the files in <code>inc/</code>."},{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"reply_to_user":{"reputation":1709,"user_id":93,"user_type":"registered","accept_rate":55,"profile_image":"https://www.gravatar.com/avatar/52ada69db49a5d75240cc0c989c934f4?s=128&d=identicon&r=PG","display_name":"nispio","link":"http://emacs.stackexchange.com/users/93/nispio"},"edited":false,"score":2,"post_type":"answer","creation_date":1414737857,"post_id":2893,"comment_id":3945,"body_markdown":"There's no way to interactively add to project list. But you may try manually adding a directory to `projectile-known-projects`. You could also look at this [issue](https://github.com/bbatsov/projectile/issues/364). Probably you should update the issue, so someone could add this feature.","link":"http://emacs.stackexchange.com/questions/2891/projectile-project-in-folder-without-write-access/2893#comment3945_2893","body":"There's no way to interactively add to project list. But you may try manually adding a directory to <code>projectile-known-projects</code>. You could also look at this <a href=\"https://github.com/bbatsov/projectile/issues/364\" rel=\"nofollow\">issue</a>. Probably you should update the issue, so someone could add this feature."},{"owner":{"reputation":1709,"user_id":93,"user_type":"registered","accept_rate":55,"profile_image":"https://www.gravatar.com/avatar/52ada69db49a5d75240cc0c989c934f4?s=128&d=identicon&r=PG","display_name":"nispio","link":"http://emacs.stackexchange.com/users/93/nispio"},"edited":false,"score":0,"post_type":"answer","creation_date":1414784253,"post_id":2893,"comment_id":4008,"body_markdown":"Adding to `projectile-known-projects` suffered from the same subdirectory issue that I mentioned in my first comment. I did add a comment to the GitHub issue though, and I got a helpful response.","link":"http://emacs.stackexchange.com/questions/2891/projectile-project-in-folder-without-write-access/2893#comment4008_2893","body":"Adding to <code>projectile-known-projects</code> suffered from the same subdirectory issue that I mentioned in my first comment. I did add a comment to the GitHub issue though, and I got a helpful response."}],"comment_count":3,"is_accepted":false,"score":1,"last_activity_date":1414736337,"creation_date":1414736337,"answer_id":2893,"question_id":2891,"body_markdown":"In that case, you can temporary disable `projectile-require-project-root`:\r\n\r\n (setq projectile-require-project-root nil)\r\n\r\nThen, you can activate Projectile everywhere.","link":"http://emacs.stackexchange.com/questions/2891/projectile-project-in-folder-without-write-access/2893#2893","title":"Projectile project in folder without write access?","body":"<p>In that case, you can temporary disable <code>projectile-require-project-root</code>:</p>\n\n<pre><code>(setq projectile-require-project-root nil)\n</code></pre>\n\n<p>Then, you can activate Projectile everywhere.</p>\n"},{"owner":{"reputation":1709,"user_id":93,"user_type":"registered","accept_rate":55,"profile_image":"https://www.gravatar.com/avatar/52ada69db49a5d75240cc0c989c934f4?s=128&d=identicon&r=PG","display_name":"nispio","link":"http://emacs.stackexchange.com/users/93/nispio"},"comment_count":0,"is_accepted":false,"score":1,"last_activity_date":1414784284,"creation_date":1414784284,"answer_id":2924,"question_id":2891,"body_markdown":"GitHub user thomasf [provided a workaround][1] which I modified only slightly:\r\n\r\n ;; (source: https://github.com/bbatsov/projectile/issues/364#issuecomment-61296248)\r\n (defun projectile-root-child-of (dir &optional list)\r\n (projectile-locate-dominating-file\r\n dir\r\n (lambda (dir)\r\n \t (--first\r\n \t (if (and\r\n \t\t (s-equals? (file-remote-p it) (file-remote-p dir))\r\n \t\t (string-match-p (expand-file-name it) (expand-file-name dir)))\r\n \t\t dir)\r\n \t (or list project-root-regexps (list))))))\r\n \r\n (defvar project-root-regexps ()\r\n "List of regexps to match against when projectile is searching\r\n for project root directories.")\r\n \r\n (add-to-list 'project-root-regexps "/path/to/some/project/$")\r\n (add-to-list 'project-root-regexps "/path/to/another/project/$")\r\n (add-to-list 'project-root-regexps "/path/to/one/more/project/$")\r\n \r\n (nconc projectile-project-root-files-functions '(projectile-root-child-of))\r\n\r\nThis lets me add projects to to the list `project-root-regexps`, and as far as I can tell they behave just as if they had a `.projectile` file at their root.\r\n\r\n\r\n [1]: https://github.com/bbatsov/projectile/issues/364#issuecomment-61296248","link":"http://emacs.stackexchange.com/questions/2891/projectile-project-in-folder-without-write-access/2924#2924","title":"Projectile project in folder without write access?","body":"<p>GitHub user thomasf <a href=\"https://github.com/bbatsov/projectile/issues/364#issuecomment-61296248\" rel=\"nofollow\">provided a workaround</a> which I modified only slightly:</p>\n\n<pre><code>;; (source: https://github.com/bbatsov/projectile/issues/364#issuecomment-61296248)\n(defun projectile-root-child-of (dir &optional list)\n (projectile-locate-dominating-file\n dir\n (lambda (dir)\n (--first\n (if (and\n (s-equals? (file-remote-p it) (file-remote-p dir))\n (string-match-p (expand-file-name it) (expand-file-name dir)))\n dir)\n (or list project-root-regexps (list))))))\n\n(defvar project-root-regexps ()\n \"List of regexps to match against when projectile is searching\n for project root directories.\")\n\n(add-to-list 'project-root-regexps \"/path/to/some/project/$\")\n(add-to-list 'project-root-regexps \"/path/to/another/project/$\")\n(add-to-list 'project-root-regexps \"/path/to/one/more/project/$\")\n\n(nconc projectile-project-root-files-functions '(projectile-root-child-of))\n</code></pre>\n\n<p>This lets me add projects to to the list <code>project-root-regexps</code>, and as far as I can tell they behave just as if they had a <code>.projectile</code> file at their root.</p>\n"}],"tags":["projectile"],"owner":{"reputation":1709,"user_id":93,"user_type":"registered","accept_rate":55,"profile_image":"https://www.gravatar.com/avatar/52ada69db49a5d75240cc0c989c934f4?s=128&d=identicon&r=PG","display_name":"nispio","link":"http://emacs.stackexchange.com/users/93/nispio"},"comment_count":0,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":31,"favorite_count":0,"answer_count":2,"score":2,"last_activity_date":1414784284,"creation_date":1414735834,"question_id":2891,"body_markdown":"At times I want to browse the code of projects to which I have read-only access. This makes it impossible for me to drop a `.projectile` file at the root of the project.\r\n\r\nIs there a way to define projects for use with projectile when I do not have write access to the project directories?","link":"http://emacs.stackexchange.com/questions/2891/projectile-project-in-folder-without-write-access","title":"Projectile project in folder without write access?","body":"<p>At times I want to browse the code of projects to which I have read-only access. This makes it impossible for me to drop a <code>.projectile</code> file at the root of the project.</p>\n\n<p>Is there a way to define projects for use with projectile when I do not have write access to the project directories?</p>\n"},{"answers":[{"owner":{"reputation":181,"user_id":795,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/75a3213bbcaf279ab4ec2787060c37d4?s=128&d=identicon&r=PG","display_name":"sds","link":"http://emacs.stackexchange.com/users/795/sds"},"comments":[{"owner":{"reputation":420,"user_id":2094,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6da30f549b191206a744fbab8003d0b5?s=128&d=identicon&r=PG","display_name":"abo-abo","link":"http://emacs.stackexchange.com/users/2094/abo-abo"},"edited":false,"score":0,"post_type":"answer","creation_date":1414768706,"post_id":2918,"comment_id":3983,"body_markdown":"Nope, doesn't work.","link":"http://emacs.stackexchange.com/questions/2917/how-to-disable-eldoc-for-eval-expression/2918#comment3983_2918","body":"Nope, doesn't work."},{"owner":{"reputation":181,"user_id":795,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/75a3213bbcaf279ab4ec2787060c37d4?s=128&d=identicon&r=PG","display_name":"sds","link":"http://emacs.stackexchange.com/users/795/sds"},"reply_to_user":{"reputation":420,"user_id":2094,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6da30f549b191206a744fbab8003d0b5?s=128&d=identicon&r=PG","display_name":"abo-abo","link":"http://emacs.stackexchange.com/users/2094/abo-abo"},"edited":false,"score":0,"post_type":"answer","creation_date":1414769011,"post_id":2918,"comment_id":3984,"body_markdown":"check buffer-local values of `eldoc-mode`.","link":"http://emacs.stackexchange.com/questions/2917/how-to-disable-eldoc-for-eval-expression/2918#comment3984_2918","body":"check buffer-local values of <code>eldoc-mode</code>."},{"owner":{"reputation":420,"user_id":2094,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6da30f549b191206a744fbab8003d0b5?s=128&d=identicon&r=PG","display_name":"abo-abo","link":"http://emacs.stackexchange.com/users/2094/abo-abo"},"edited":false,"score":0,"post_type":"answer","creation_date":1414769673,"post_id":2918,"comment_id":3985,"body_markdown":"Setting `eldoc-idle-delay` works, but how would I disable `eldoc-mode` for minibuffer?\nI tried `minibuffer-setup-hook`, it didn't work.","link":"http://emacs.stackexchange.com/questions/2917/how-to-disable-eldoc-for-eval-expression/2918#comment3985_2918","body":"Setting <code>eldoc-idle-delay</code> works, but how would I disable <code>eldoc-mode</code> for minibuffer? I tried <code>minibuffer-setup-hook</code>, it didn't work."},{"owner":{"reputation":181,"user_id":795,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/75a3213bbcaf279ab4ec2787060c37d4?s=128&d=identicon&r=PG","display_name":"sds","link":"http://emacs.stackexchange.com/users/795/sds"},"reply_to_user":{"reputation":420,"user_id":2094,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6da30f549b191206a744fbab8003d0b5?s=128&d=identicon&r=PG","display_name":"abo-abo","link":"http://emacs.stackexchange.com/users/2094/abo-abo"},"edited":false,"score":0,"post_type":"answer","creation_date":1414769738,"post_id":2918,"comment_id":3986,"body_markdown":"wdym "disable eldoc-mode for minibuffer"? just kill the timer","link":"http://emacs.stackexchange.com/questions/2917/how-to-disable-eldoc-for-eval-expression/2918#comment3986_2918","body":"wdym "disable eldoc-mode for minibuffer"? just kill the timer"},{"owner":{"reputation":420,"user_id":2094,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6da30f549b191206a744fbab8003d0b5?s=128&d=identicon&r=PG","display_name":"abo-abo","link":"http://emacs.stackexchange.com/users/2094/abo-abo"},"edited":false,"score":0,"post_type":"answer","creation_date":1414770039,"post_id":2918,"comment_id":3987,"body_markdown":"Killing the timer doesn't work. Tested with `emacs -Q`.","link":"http://emacs.stackexchange.com/questions/2917/how-to-disable-eldoc-for-eval-expression/2918#comment3987_2918","body":"Killing the timer doesn't work. Tested with <code>emacs -Q</code>."},{"owner":{"reputation":181,"user_id":795,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/75a3213bbcaf279ab4ec2787060c37d4?s=128&d=identicon&r=PG","display_name":"sds","link":"http://emacs.stackexchange.com/users/795/sds"},"reply_to_user":{"reputation":420,"user_id":2094,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6da30f549b191206a744fbab8003d0b5?s=128&d=identicon&r=PG","display_name":"abo-abo","link":"http://emacs.stackexchange.com/users/2094/abo-abo"},"edited":false,"score":0,"post_type":"answer","creation_date":1414770147,"post_id":2918,"comment_id":3988,"body_markdown":"`(global-eldoc-mode nil)` works with `emacs -Q`","link":"http://emacs.stackexchange.com/questions/2917/how-to-disable-eldoc-for-eval-expression/2918#comment3988_2918","body":"<code>(global-eldoc-mode nil)</code> works with <code>emacs -Q</code>"},{"owner":{"reputation":420,"user_id":2094,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6da30f549b191206a744fbab8003d0b5?s=128&d=identicon&r=PG","display_name":"abo-abo","link":"http://emacs.stackexchange.com/users/2094/abo-abo"},"edited":false,"score":0,"post_type":"answer","creation_date":1414770240,"post_id":2918,"comment_id":3989,"body_markdown":"No, it doesn't on today's build. Just `eval-expression`, type `(+` and the hint will appear in the modeline. All with `emacs -Q`","link":"http://emacs.stackexchange.com/questions/2917/how-to-disable-eldoc-for-eval-expression/2918#comment3989_2918","body":"No, it doesn't on today's build. Just <code>eval-expression</code>, type <code>(+</code> and the hint will appear in the modeline. All with <code>emacs -Q</code>"},{"owner":{"reputation":181,"user_id":795,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/75a3213bbcaf279ab4ec2787060c37d4?s=128&d=identicon&r=PG","display_name":"sds","link":"http://emacs.stackexchange.com/users/795/sds"},"reply_to_user":{"reputation":420,"user_id":2094,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6da30f549b191206a744fbab8003d0b5?s=128&d=identicon&r=PG","display_name":"abo-abo","link":"http://emacs.stackexchange.com/users/2094/abo-abo"},"edited":false,"score":0,"post_type":"answer","creation_date":1414770391,"post_id":2918,"comment_id":3990,"body_markdown":"Problems with dev builds should be discussed on `emacs-devel` mailing list. SE is for long term knowledge.","link":"http://emacs.stackexchange.com/questions/2917/how-to-disable-eldoc-for-eval-expression/2918#comment3990_2918","body":"Problems with dev builds should be discussed on <code>emacs-devel</code> mailing list. SE is for long term knowledge."},{"owner":{"reputation":631,"user_id":1979,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6d7d7689f9562293f6106353a6b1a905?s=128&d=identicon&r=PG","display_name":"Stefan","link":"http://emacs.stackexchange.com/users/1979/stefan"},"edited":false,"score":0,"post_type":"answer","creation_date":1414776358,"post_id":2918,"comment_id":3997,"body_markdown":"It should be `(global-eldoc-mode -1)`: `nil` for minor modes used to mean "toggle" but nowadays it means "enable".","link":"http://emacs.stackexchange.com/questions/2917/how-to-disable-eldoc-for-eval-expression/2918#comment3997_2918","body":"It should be <code>(global-eldoc-mode -1)</code>: <code>nil</code> for minor modes used to mean "toggle" but nowadays it means "enable"."},{"owner":{"reputation":181,"user_id":795,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/75a3213bbcaf279ab4ec2787060c37d4?s=128&d=identicon&r=PG","display_name":"sds","link":"http://emacs.stackexchange.com/users/795/sds"},"reply_to_user":{"reputation":631,"user_id":1979,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6d7d7689f9562293f6106353a6b1a905?s=128&d=identicon&r=PG","display_name":"Stefan","link":"http://emacs.stackexchange.com/users/1979/stefan"},"edited":false,"score":0,"post_type":"answer","creation_date":1414776443,"post_id":2918,"comment_id":3998,"body_markdown":"Thanks @Stefan - why was such a counter-intuitive change made?","link":"http://emacs.stackexchange.com/questions/2917/how-to-disable-eldoc-for-eval-expression/2918#comment3998_2918","body":"Thanks @Stefan - why was such a counter-intuitive change made?"},{"owner":{"reputation":631,"user_id":1979,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6d7d7689f9562293f6106353a6b1a905?s=128&d=identicon&r=PG","display_name":"Stefan","link":"http://emacs.stackexchange.com/users/1979/stefan"},"edited":false,"score":0,"post_type":"answer","creation_date":1414776751,"post_id":2918,"comment_id":3999,"body_markdown":"Because "toggle" is virtually never the behavior that's needed when called non-interactively. This change fixed latent bugs for all those people who had `(add-hook 'foo-mode-hook 'bar-mode)` in their .emacs. A side-benefit is that we don't need any `turn-on-foo-mode` any more.","link":"http://emacs.stackexchange.com/questions/2917/how-to-disable-eldoc-for-eval-expression/2918#comment3999_2918","body":"Because "toggle" is virtually never the behavior that's needed when called non-interactively. This change fixed latent bugs for all those people who had <code>(add-hook 'foo-mode-hook 'bar-mode)</code> in their .emacs. A side-benefit is that we don't need any <code>turn-on-foo-mode</code> any more."}],"last_editor":{"reputation":181,"user_id":795,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/75a3213bbcaf279ab4ec2787060c37d4?s=128&d=identicon&r=PG","display_name":"sds","link":"http://emacs.stackexchange.com/users/795/sds"},"comment_count":11,"is_accepted":true,"score":2,"last_activity_date":1414776394,"last_edit_date":1414776394,"creation_date":1414768610,"answer_id":2918,"question_id":2917,"body_markdown":"Disable it globally:\r\n\r\n (global-eldoc-mode -1)\r\n\r\nDisable it locally - make sure that `eldoc-mode` is `nil` in all your buffers.\r\n\r\nA less drastic solution would be to increase `eldoc-idle-delay`.\r\n","link":"http://emacs.stackexchange.com/questions/2917/how-to-disable-eldoc-for-eval-expression/2918#2918","title":"How to disable eldoc for `eval-expression`?","body":"<p>Disable it globally:</p>\n\n<pre><code>(global-eldoc-mode -1)\n</code></pre>\n\n<p>Disable it locally - make sure that <code>eldoc-mode</code> is <code>nil</code> in all your buffers.</p>\n\n<p>A less drastic solution would be to increase <code>eldoc-idle-delay</code>.</p>\n"}],"tags":["elisp","emacs-25"],"owner":{"reputation":420,"user_id":2094,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6da30f549b191206a744fbab8003d0b5?s=128&d=identicon&r=PG","display_name":"abo-abo","link":"http://emacs.stackexchange.com/users/2094/abo-abo"},"last_editor":{"reputation":1001,"user_id":337,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/95c16e08edbfaf21de8e6fe15e0ba4c6?s=128&d=identicon&r=PG","display_name":"Jonathan Leech-Pepin","link":"http://emacs.stackexchange.com/users/337/jonathan-leech-pepin"},"comment_count":0,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":32,"favorite_count":0,"accepted_answer_id":2918,"answer_count":1,"score":1,"last_activity_date":1414776394,"creation_date":1414767244,"last_edit_date":1414770569,"question_id":2917,"body_markdown":"After a recent update `eldoc` is turned on by default, even for `emacs -Q`.\r\nI don't appreciate the noise it generates when I'm using `eval-expression`.\r\nHow do I turn it off?","link":"http://emacs.stackexchange.com/questions/2917/how-to-disable-eldoc-for-eval-expression","title":"How to disable eldoc for `eval-expression`?","body":"<p>After a recent update <code>eldoc</code> is turned on by default, even for <code>emacs -Q</code>.\nI don't appreciate the noise it generates when I'm using <code>eval-expression</code>.\nHow do I turn it off?</p>\n"},{"answers":[{"owner":{"reputation":466,"user_id":220,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/8dff5903c3d337d048b6b908e0be9e9b?s=128&d=identicon&r=PG","display_name":"kmicu","link":"http://emacs.stackexchange.com/users/220/kmicu"},"comment_count":0,"is_accepted":false,"score":1,"last_activity_date":1414775451,"creation_date":1414775451,"answer_id":2923,"question_id":972,"body_markdown":"With `csv-mode` I can see some lags with your file, but only with syntax highlighting enabled. After disabling fontification with `M-x font-lock-mode` it works without problems.\r\n\r\nTo disable it permanently for `csv-mode` add to your config:\r\n\r\n (add-hook 'csv-mode-hook (lambda () (font-lock-mode -1))\r\n\r\nOr if you are a [use-package][1] user:\r\n\r\n (use-package csv-mode\r\n :mode ("\\\\.csv\\\\'" . csv-mode)\r\n :init (add-hook 'csv-mode-hook (lambda () (font-lock-mode -1)))\r\n :ensure t)\r\n\r\n\r\n [1]: https://github.com/jwiegley/use-package","link":"http://emacs.stackexchange.com/questions/972/how-to-view-and-edit-large-delimiter-separated-value-files/2923#2923","title":"How to view and edit large delimiter separated value files?","body":"<p>With <code>csv-mode</code> I can see some lags with your file, but only with syntax highlighting enabled. After disabling fontification with <code>M-x font-lock-mode</code> it works without problems.</p>\n\n<p>To disable it permanently for <code>csv-mode</code> add to your config:</p>\n\n<pre><code>(add-hook 'csv-mode-hook (lambda () (font-lock-mode -1))\n</code></pre>\n\n<p>Or if you are a <a href=\"https://github.com/jwiegley/use-package\" rel=\"nofollow\">use-package</a> user:</p>\n\n<pre><code>(use-package csv-mode\n :mode (\"\\\\.csv\\\\'\" . csv-mode)\n :init (add-hook 'csv-mode-hook (lambda () (font-lock-mode -1)))\n :ensure t)\n</code></pre>\n"}],"tags":["editing","table","large-files","csv"],"owner":{"reputation":48,"user_id":315,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/912d39713cb1441439c578a3c286eca7?s=128&d=identicon&r=PG","display_name":"holocronweaver","link":"http://emacs.stackexchange.com/users/315/holocronweaver"},"comments":[{"owner":{"reputation":362,"user_id":55,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/6d08a2f792f289b95fe1d982d4133d71?s=128&d=identicon&r=PG","display_name":"wdkrnls","link":"http://emacs.stackexchange.com/users/55/wdkrnls"},"edited":false,"score":2,"post_type":"question","creation_date":1412892816,"post_id":972,"comment_id":1383,"body_markdown":"Table editing is not one of Emacs's current strengths. I wish it was. I'd rather never have to use a dedicated spreadsheet.","link":"http://emacs.stackexchange.com/questions/972/how-to-view-and-edit-large-delimiter-separated-value-files#comment1383_972","body":"Table editing is not one of Emacs's current strengths. I wish it was. I'd rather never have to use a dedicated spreadsheet."},{"owner":{"reputation":631,"user_id":1979,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6d7d7689f9562293f6106353a6b1a905?s=128&d=identicon&r=PG","display_name":"Stefan","link":"http://emacs.stackexchange.com/users/1979/stefan"},"edited":false,"score":0,"post_type":"question","creation_date":1413305227,"post_id":972,"comment_id":2717,"body_markdown":"Not a short-term answer, but you might want to `M-x report-emacs-bug` about it, ideally with a recipe to reproduce the slow-down. There's probably a lot of room for improvement in `csv-mode`.","link":"http://emacs.stackexchange.com/questions/972/how-to-view-and-edit-large-delimiter-separated-value-files#comment2717_972","body":"Not a short-term answer, but you might want to <code>M-x report-emacs-bug</code> about it, ideally with a recipe to reproduce the slow-down. There's probably a lot of room for improvement in <code>csv-mode</code>."},{"owner":{"reputation":897,"user_id":304,"user_type":"registered","accept_rate":62,"profile_image":"https://www.gravatar.com/avatar/1f86c0bc40235a9edf351a16b859aabd?s=128&d=identicon&r=PG","display_name":"Wilfred Hughes","link":"http://emacs.stackexchange.com/users/304/wilfred-hughes"},"edited":false,"score":2,"post_type":"question","creation_date":1413359737,"post_id":972,"comment_id":2767,"body_markdown":"Do you have a sample file that demonstrates the problem?","link":"http://emacs.stackexchange.com/questions/972/how-to-view-and-edit-large-delimiter-separated-value-files#comment2767_972","body":"Do you have a sample file that demonstrates the problem?"},{"owner":{"reputation":48,"user_id":315,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/912d39713cb1441439c578a3c286eca7?s=128&d=identicon&r=PG","display_name":"holocronweaver","link":"http://emacs.stackexchange.com/users/315/holocronweaver"},"edited":false,"score":0,"post_type":"question","creation_date":1414713159,"post_id":972,"comment_id":3931,"body_markdown":"Yes, yes I do. Added to question.","link":"http://emacs.stackexchange.com/questions/972/how-to-view-and-edit-large-delimiter-separated-value-files#comment3931_972","body":"Yes, yes I do. Added to question."}],"last_editor":{"reputation":48,"user_id":315,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/912d39713cb1441439c578a3c286eca7?s=128&d=identicon&r=PG","display_name":"holocronweaver","link":"http://emacs.stackexchange.com/users/315/holocronweaver"},"comment_count":4,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":88,"favorite_count":0,"answer_count":1,"score":5,"last_activity_date":1414775451,"creation_date":1412881152,"last_edit_date":1414713136,"question_id":972,"body_markdown":"I have been using `csv-mode` to modify small to medium sized CSV files, but recently I have been working with large files containing more than 40,812 entries. `csv-mode` struggles to align and navigate the tables, and is too slow to be usable as is. In comparison, LibreOffice Calc can zip through the file.\r\n\r\nIs there a simple way to make `csv-mode` handle large tables, or is there a better approach available?\r\n\r\nI am aware of [a related Stack Overflow question](http://stackoverflow.com/questions/10616525/is-there-a-good-emacs-mode-for-displaying-and-editing-huge-delimiter-separated-f). Its solution was to only align the portion of buffer in the visible window, but this did not solve the sluggishness in my case.\r\n\r\n[Here is an example file.][1] I tried to make it large, but not so large it will freeze Emacs on older computers.\r\n\r\n\r\n [1]: https://www.dropbox.com/s/xmt4s5i5ikq0i0v/big.csv?dl=0","link":"http://emacs.stackexchange.com/questions/972/how-to-view-and-edit-large-delimiter-separated-value-files","title":"How to view and edit large delimiter separated value files?","body":"<p>I have been using <code>csv-mode</code> to modify small to medium sized CSV files, but recently I have been working with large files containing more than 40,812 entries. <code>csv-mode</code> struggles to align and navigate the tables, and is too slow to be usable as is. In comparison, LibreOffice Calc can zip through the file.</p>\n\n<p>Is there a simple way to make <code>csv-mode</code> handle large tables, or is there a better approach available?</p>\n\n<p>I am aware of <a href=\"http://stackoverflow.com/questions/10616525/is-there-a-good-emacs-mode-for-displaying-and-editing-huge-delimiter-separated-f\">a related Stack Overflow question</a>. Its solution was to only align the portion of buffer in the visible window, but this did not solve the sluggishness in my case.</p>\n\n<p><a href=\"https://www.dropbox.com/s/xmt4s5i5ikq0i0v/big.csv?dl=0\" rel=\"nofollow\">Here is an example file.</a> I tried to make it large, but not so large it will freeze Emacs on older computers.</p>\n"},{"answers":[{"owner":{"reputation":1487,"user_id":160,"user_type":"registered","profile_image":"http://i.stack.imgur.com/y27jq.png?s=128&g=1","display_name":"Jordon Biondo","link":"http://emacs.stackexchange.com/users/160/jordon-biondo"},"comment_count":0,"is_accepted":false,"score":1,"last_activity_date":1414773563,"creation_date":1414773563,"answer_id":2921,"question_id":2884,"body_markdown":"[web-mode][1] has element folding built in and bound to <kbd>C-c</kbd> <kbd>C-f</kbd>. But you will lose some of the features of using nxml-mode obviously.\r\n\r\n [1]: http://web-mode.org/","link":"http://emacs.stackexchange.com/questions/2884/the-old-how-to-fold-xml-question/2921#2921","title":"The old "how to fold xml" question","body":"<p><a href=\"http://web-mode.org/\" rel=\"nofollow\">web-mode</a> has element folding built in and bound to <kbd>C-c</kbd> <kbd>C-f</kbd>. But you will lose some of the features of using nxml-mode obviously.</p>\n"}],"tags":["xml","nxml","outline"],"owner":{"reputation":193,"user_id":215,"user_type":"registered","profile_image":"http://i.stack.imgur.com/y7fBO.png?s=128&g=1","display_name":"Mark Aufflick","link":"http://emacs.stackexchange.com/users/215/mark-aufflick"},"comment_count":0,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":24,"favorite_count":0,"answer_count":1,"score":3,"last_activity_date":1414773563,"creation_date":1414720950,"question_id":2884,"body_markdown":"I'm doing quite a bit of manual xml editing (the source definition of some code generation I'm doing is a custom xml format) and of course prefer to use Emacs over any special purpose (usually ugly) xml editors. nXml mode has stood me well in the past, but I cannot get my head around it's "outline" support. Various internet and SO posts effectively say nothing - I'm wondering if anyone has any practical experience with outlining/folding xml in emacs (any mode) whether or not that requires altering the xml structure itself.","link":"http://emacs.stackexchange.com/questions/2884/the-old-how-to-fold-xml-question","title":"The old "how to fold xml" question","body":"<p>I'm doing quite a bit of manual xml editing (the source definition of some code generation I'm doing is a custom xml format) and of course prefer to use Emacs over any special purpose (usually ugly) xml editors. nXml mode has stood me well in the past, but I cannot get my head around it's \"outline\" support. Various internet and SO posts effectively say nothing - I'm wondering if anyone has any practical experience with outlining/folding xml in emacs (any mode) whether or not that requires altering the xml structure itself.</p>\n"},{"answers":[{"owner":{"reputation":420,"user_id":2094,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6da30f549b191206a744fbab8003d0b5?s=128&d=identicon&r=PG","display_name":"abo-abo","link":"http://emacs.stackexchange.com/users/2094/abo-abo"},"comment_count":0,"is_accepted":true,"score":4,"last_activity_date":1414766835,"creation_date":1414766835,"answer_id":2916,"question_id":2914,"body_markdown":"<kbd>v x 10 RET</kbd> should do it. Uses `calc-index`.\r\n","link":"http://emacs.stackexchange.com/questions/2914/how-can-i-turn-1-10-into-1-2-3-4-5-6-7-8-9-10-in-calc/2916#2916","title":"How can I turn [1..10] into [1,2,3,4,5,6,7,8,9,10] in calc?","body":"<p><kbd>v x 10 RET</kbd> should do it. Uses <code>calc-index</code>.</p>\n"}],"tags":["calc"],"owner":{"reputation":113,"user_id":503,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/db83b716acfe0f3a1de6faa176d63fca?s=128&d=identicon&r=PG&f=1","display_name":"MrBones","link":"http://emacs.stackexchange.com/users/503/mrbones"},"comment_count":0,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":100,"favorite_count":0,"accepted_answer_id":2916,"answer_count":1,"score":2,"last_activity_date":1414766835,"creation_date":1414765664,"question_id":2914,"body_markdown":"When playing around with data in `calc`, I often want to generate a vector from an interval.\r\n\r\nHow can I easily create a vector from just a start point, end point & step value.\r\n\r\nSomething like `1 <RET> 10 <RET> 1 MAKE-VECTOR` to give me `[1,2,3,4,5,6,7,8,9,10]`?","link":"http://emacs.stackexchange.com/questions/2914/how-can-i-turn-1-10-into-1-2-3-4-5-6-7-8-9-10-in-calc","title":"How can I turn [1..10] into [1,2,3,4,5,6,7,8,9,10] in calc?","body":"<p>When playing around with data in <code>calc</code>, I often want to generate a vector from an interval.</p>\n\n<p>How can I easily create a vector from just a start point, end point & step value.</p>\n\n<p>Something like <code>1 <RET> 10 <RET> 1 MAKE-VECTOR</code> to give me <code>[1,2,3,4,5,6,7,8,9,10]</code>?</p>\n"},{"answers":[{"owner":{"reputation":181,"user_id":795,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/75a3213bbcaf279ab4ec2787060c37d4?s=128&d=identicon&r=PG","display_name":"sds","link":"http://emacs.stackexchange.com/users/795/sds"},"last_editor":{"reputation":181,"user_id":795,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/75a3213bbcaf279ab4ec2787060c37d4?s=128&d=identicon&r=PG","display_name":"sds","link":"http://emacs.stackexchange.com/users/795/sds"},"comment_count":0,"is_accepted":true,"score":3,"last_activity_date":1414763211,"last_edit_date":1414763211,"creation_date":1414762888,"answer_id":2913,"question_id":2907,"body_markdown":"There are two ways\r\n=\r\nRedefine `lisp--match-hidden-arg`:\r\n-\r\n (defun lisp--match-hidden-arg (limit) nil)\r\n\r\nRemove `lisp--match-hidden-arg` from `lisp-cl-font-lock-keywords-2` and `lisp-el-font-lock-keywords-2`\r\n-\r\n (setq lisp-el-font-lock-keywords-2\r\n (cl-delete 'lisp--match-hidden-arg lisp-el-font-lock-keywords-2\r\n :key #'car))\r\n\r\nPlease Do _NOT_ Do That!\r\n=\r\nThe coding style detected by `lisp--match-hidden-arg` is not very readable.\r\n\r\n> "... a computer language is not just a way of getting a computer to\r\n> perform operations, but rather ... it is a novel formal medium for\r\n> expressing ideas about methodology" \r\n\r\n> Abelson/Sussman "Structure and\r\n> Interpretation of Computer Programs".\r\n\r\nYou write code so that people (and you yourself a year from today!) will read and _understand_ it.\r\nCoding conventions serve a purpose.\r\nPlease think before rejecting them.","link":"http://emacs.stackexchange.com/questions/2907/how-to-turn-off-error-highlighting-in-emacs-lisp-mode-for-emacs-25/2913#2913","title":"How to turn off "error" highlighting in emacs-lisp-mode for Emacs 25?","body":"<h1>There are two ways</h1>\n\n<h2>Redefine <code>lisp--match-hidden-arg</code>:</h2>\n\n<pre><code>(defun lisp--match-hidden-arg (limit) nil)\n</code></pre>\n\n<h2>Remove <code>lisp--match-hidden-arg</code> from <code>lisp-cl-font-lock-keywords-2</code> and <code>lisp-el-font-lock-keywords-2</code></h2>\n\n<pre><code>(setq lisp-el-font-lock-keywords-2\n (cl-delete 'lisp--match-hidden-arg lisp-el-font-lock-keywords-2\n :key #'car))\n</code></pre>\n\n<h1>Please Do <em>NOT</em> Do That!</h1>\n\n<p>The coding style detected by <code>lisp--match-hidden-arg</code> is not very readable.</p>\n\n<blockquote>\n <p>\"... a computer language is not just a way of getting a computer to\n perform operations, but rather ... it is a novel formal medium for\n expressing ideas about methodology\" </p>\n \n <p>Abelson/Sussman \"Structure and\n Interpretation of Computer Programs\".</p>\n</blockquote>\n\n<p>You write code so that people (and you yourself a year from today!) will read and <em>understand</em> it.\nCoding conventions serve a purpose.\nPlease think before rejecting them.</p>\n"}],"tags":["elisp","font-lock","emacs-lisp-mode"],"owner":{"reputation":420,"user_id":2094,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6da30f549b191206a744fbab8003d0b5?s=128&d=identicon&r=PG","display_name":"abo-abo","link":"http://emacs.stackexchange.com/users/2094/abo-abo"},"comments":[{"owner":{"reputation":2563,"user_id":115,"user_type":"registered","accept_rate":88,"profile_image":"https://www.gravatar.com/avatar/6dbe470c7ef3817bb1da85dc5883acbe?s=128&d=identicon&r=PG","display_name":"kaushalmodi","link":"http://emacs.stackexchange.com/users/115/kaushalmodi"},"edited":false,"score":0,"post_type":"question","creation_date":1414761331,"post_id":2907,"comment_id":3965,"body_markdown":"Could it be the theme? I was tweaking [`zop-to-char`](https://github.com/thierryvolpiatto/zop-to-char) yesterday and I don't see that `nil` highlighted in `font-lock-warning-face`: [My screenshot](http://i.imgur.com/nI7ZwX7.png?1). I am also on 24.4. The difference I guess is that I am using `zenburn` theme. And it does highlight `font-lock-warning-face` at places I expect.","link":"http://emacs.stackexchange.com/questions/2907/how-to-turn-off-error-highlighting-in-emacs-lisp-mode-for-emacs-25#comment3965_2907","body":"Could it be the theme? I was tweaking <a href=\"https://github.com/thierryvolpiatto/zop-to-char\" rel=\"nofollow\"><code>zop-to-char</code></a> yesterday and I don't see that <code>nil</code> highlighted in <code>font-lock-warning-face</code>: <a href=\"http://i.imgur.com/nI7ZwX7.png?1\" rel=\"nofollow\">My screenshot</a>. I am also on 24.4. The difference I guess is that I am using <code>zenburn</code> theme. And it does highlight <code>font-lock-warning-face</code> at places I expect."},{"owner":{"reputation":420,"user_id":2094,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6da30f549b191206a744fbab8003d0b5?s=128&d=identicon&r=PG","display_name":"abo-abo","link":"http://emacs.stackexchange.com/users/2094/abo-abo"},"reply_to_user":{"reputation":2563,"user_id":115,"user_type":"registered","accept_rate":88,"profile_image":"https://www.gravatar.com/avatar/6dbe470c7ef3817bb1da85dc5883acbe?s=128&d=identicon&r=PG","display_name":"kaushalmodi","link":"http://emacs.stackexchange.com/users/115/kaushalmodi"},"edited":false,"score":0,"post_type":"question","creation_date":1414761494,"post_id":2907,"comment_id":3966,"body_markdown":"It's reproducible with `emacs -Q`.","link":"http://emacs.stackexchange.com/questions/2907/how-to-turn-off-error-highlighting-in-emacs-lisp-mode-for-emacs-25#comment3966_2907","body":"It's reproducible with <code>emacs -Q</code>."},{"owner":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":0,"post_type":"question","creation_date":1414761621,"post_id":2907,"comment_id":3967,"body_markdown":"I can confirm this does happen. I find it useful because it highlights that the return value is not what it seems.","link":"http://emacs.stackexchange.com/questions/2907/how-to-turn-off-error-highlighting-in-emacs-lisp-mode-for-emacs-25#comment3967_2907","body":"I can confirm this does happen. I find it useful because it highlights that the return value is not what it seems."},{"owner":{"reputation":2563,"user_id":115,"user_type":"registered","accept_rate":88,"profile_image":"https://www.gravatar.com/avatar/6dbe470c7ef3817bb1da85dc5883acbe?s=128&d=identicon&r=PG","display_name":"kaushalmodi","link":"http://emacs.stackexchange.com/users/115/kaushalmodi"},"edited":false,"score":0,"post_type":"question","creation_date":1414762049,"post_id":2907,"comment_id":3968,"body_markdown":"Strange.. why am I not seeing that even on `emacs -Q`? [Screenshot](http://i.imgur.com/YcACYO0.png). Again, I am also using emacs 24.4.","link":"http://emacs.stackexchange.com/questions/2907/how-to-turn-off-error-highlighting-in-emacs-lisp-mode-for-emacs-25#comment3968_2907","body":"Strange.. why am I not seeing that even on <code>emacs -Q</code>? <a href=\"http://i.imgur.com/YcACYO0.png\" rel=\"nofollow\">Screenshot</a>. Again, I am also using emacs 24.4."},{"owner":{"reputation":420,"user_id":2094,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6da30f549b191206a744fbab8003d0b5?s=128&d=identicon&r=PG","display_name":"abo-abo","link":"http://emacs.stackexchange.com/users/2094/abo-abo"},"reply_to_user":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":0,"post_type":"question","creation_date":1414762158,"post_id":2907,"comment_id":3969,"body_markdown":"@Malabarba, it highlights red because `nil` isn't on a new line. It's just a text formatting issue.","link":"http://emacs.stackexchange.com/questions/2907/how-to-turn-off-error-highlighting-in-emacs-lisp-mode-for-emacs-25#comment3969_2907","body":"@Malabarba, it highlights red because <code>nil</code> isn't on a new line. It's just a text formatting issue."},{"owner":{"reputation":2563,"user_id":115,"user_type":"registered","accept_rate":88,"profile_image":"https://www.gravatar.com/avatar/6dbe470c7ef3817bb1da85dc5883acbe?s=128&d=identicon&r=PG","display_name":"kaushalmodi","link":"http://emacs.stackexchange.com/users/115/kaushalmodi"},"reply_to_user":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":0,"post_type":"question","creation_date":1414762323,"post_id":2907,"comment_id":3970,"body_markdown":"@Malabarba, does that highlighting happen for you for [this exact code snippet](https://github.com/thierryvolpiatto/zop-to-char/blob/master/zop-to-char.el#L56-60)?","link":"http://emacs.stackexchange.com/questions/2907/how-to-turn-off-error-highlighting-in-emacs-lisp-mode-for-emacs-25#comment3970_2907","body":"@Malabarba, does that highlighting happen for you for <a href=\"https://github.com/thierryvolpiatto/zop-to-char/blob/master/zop-to-char.el#L56-60\" rel=\"nofollow\">this exact code snippet</a>?"},{"owner":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":0,"post_type":"question","creation_date":1414762363,"post_id":2907,"comment_id":3971,"body_markdown":"@abo-abo The fact that nil isn't on a newline gives the wrong impression this entire expression returns the return value of `kill-region`. Highlighting the `nil` makes it clear that the expression actually returns nil.","link":"http://emacs.stackexchange.com/questions/2907/how-to-turn-off-error-highlighting-in-emacs-lisp-mode-for-emacs-25#comment3971_2907","body":"@abo-abo The fact that nil isn't on a newline gives the wrong impression this entire expression returns the return value of <code>kill-region</code>. Highlighting the <code>nil</code> makes it clear that the expression actually returns nil."},{"owner":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"reply_to_user":{"reputation":2563,"user_id":115,"user_type":"registered","accept_rate":88,"profile_image":"https://www.gravatar.com/avatar/6dbe470c7ef3817bb1da85dc5883acbe?s=128&d=identicon&r=PG","display_name":"kaushalmodi","link":"http://emacs.stackexchange.com/users/115/kaushalmodi"},"edited":false,"score":0,"post_type":"question","creation_date":1414762672,"post_id":2907,"comment_id":3973,"body_markdown":"@kaushalmodi Yes. Though my emacs actually identifies itself as 25.0 now, so it might not be in 24.4.","link":"http://emacs.stackexchange.com/questions/2907/how-to-turn-off-error-highlighting-in-emacs-lisp-mode-for-emacs-25#comment3973_2907","body":"@kaushalmodi Yes. Though my emacs actually identifies itself as 25.0 now, so it might not be in 24.4."},{"owner":{"reputation":2563,"user_id":115,"user_type":"registered","accept_rate":88,"profile_image":"https://www.gravatar.com/avatar/6dbe470c7ef3817bb1da85dc5883acbe?s=128&d=identicon&r=PG","display_name":"kaushalmodi","link":"http://emacs.stackexchange.com/users/115/kaushalmodi"},"edited":false,"score":0,"post_type":"question","creation_date":1414762760,"post_id":2907,"comment_id":3975,"body_markdown":"Thanks for confirming that. @abo-abo Are you also on the emacs 25.0 development version? My `C-h` `v` `emacs-version` reads `24.4.8`.","link":"http://emacs.stackexchange.com/questions/2907/how-to-turn-off-error-highlighting-in-emacs-lisp-mode-for-emacs-25#comment3975_2907","body":"Thanks for confirming that. @abo-abo Are you also on the emacs 25.0 development version? My <code>C-h</code> <code>v</code> <code>emacs-version</code> reads <code>24.4.8</code>."},{"owner":{"reputation":420,"user_id":2094,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6da30f549b191206a744fbab8003d0b5?s=128&d=identicon&r=PG","display_name":"abo-abo","link":"http://emacs.stackexchange.com/users/2094/abo-abo"},"reply_to_user":{"reputation":2563,"user_id":115,"user_type":"registered","accept_rate":88,"profile_image":"https://www.gravatar.com/avatar/6dbe470c7ef3817bb1da85dc5883acbe?s=128&d=identicon&r=PG","display_name":"kaushalmodi","link":"http://emacs.stackexchange.com/users/115/kaushalmodi"},"edited":false,"score":0,"post_type":"question","creation_date":1414762929,"post_id":2907,"comment_id":3976,"body_markdown":"@kaushalmodi Yes, the issue happens for current devel version.","link":"http://emacs.stackexchange.com/questions/2907/how-to-turn-off-error-highlighting-in-emacs-lisp-mode-for-emacs-25#comment3976_2907","body":"@kaushalmodi Yes, the issue happens for current devel version."},{"owner":{"reputation":2563,"user_id":115,"user_type":"registered","accept_rate":88,"profile_image":"https://www.gravatar.com/avatar/6dbe470c7ef3817bb1da85dc5883acbe?s=128&d=identicon&r=PG","display_name":"kaushalmodi","link":"http://emacs.stackexchange.com/users/115/kaushalmodi"},"edited":false,"score":0,"post_type":"question","creation_date":1414763003,"post_id":2907,"comment_id":3977,"body_markdown":"@abo-abo Phew. We can then still rely on `emacs -Q` :) The version needs to then be updated in the question title.","link":"http://emacs.stackexchange.com/questions/2907/how-to-turn-off-error-highlighting-in-emacs-lisp-mode-for-emacs-25#comment3977_2907","body":"@abo-abo Phew. We can then still rely on <code>emacs -Q</code> :) The version needs to then be updated in the question title."}],"last_editor":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"comment_count":11,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":47,"favorite_count":0,"accepted_answer_id":2913,"answer_count":1,"score":2,"last_activity_date":1414766064,"creation_date":1414759846,"last_edit_date":1414766064,"question_id":2907,"body_markdown":"Since the update, a certain style of formatting code is highlighted with `font-lock-warning-face`:\r\n\r\n [1]: http://i.stack.imgur.com/ur3aG.png\r\n\r\nHow do I turn off this behavior?\r\n\r\n![enter image description here][1]\r\n\r\n\r\n","link":"http://emacs.stackexchange.com/questions/2907/how-to-turn-off-error-highlighting-in-emacs-lisp-mode-for-emacs-25","title":"How to turn off "error" highlighting in emacs-lisp-mode for Emacs 25?","body":"<p>Since the update, a certain style of formatting code is highlighted with <code>font-lock-warning-face</code>:</p>\n\n<p>How do I turn off this behavior?</p>\n\n<p><img src=\"http://i.stack.imgur.com/ur3aG.png\" alt=\"enter image description here\"></p>\n"},{"answers":[{"owner":{"reputation":216,"user_id":163,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/d602eadb9367e8c1a2e00c0bef73555c?s=128&d=identicon&r=PG","display_name":"dharmatech","link":"http://emacs.stackexchange.com/users/163/dharmatech"},"comment_count":0,"is_accepted":false,"score":1,"last_activity_date":1414725730,"creation_date":1414725730,"answer_id":2889,"question_id":2888,"body_markdown":"Here's a simple approach:\r\n\r\n (defun close-frame-buffer (frame)\r\n (kill-buffer\r\n (window-buffer\r\n (frame-root-window frame))))\r\n \r\n (add-hook 'delete-frame-functions 'close-frame-buffer)\r\n\r\nIt will kill a buffer even if it's open in another frame however.","link":"http://emacs.stackexchange.com/questions/2888/kill-buffer-when-frame-is-deleted/2889#2889","title":"Kill buffer when frame is deleted","body":"<p>Here's a simple approach:</p>\n\n<pre><code>(defun close-frame-buffer (frame)\n (kill-buffer\n (window-buffer\n (frame-root-window frame))))\n\n(add-hook 'delete-frame-functions 'close-frame-buffer)\n</code></pre>\n\n<p>It will kill a buffer even if it's open in another frame however.</p>\n"},{"owner":{"reputation":1348,"user_id":253,"user_type":"registered","accept_rate":54,"profile_image":"http://i.stack.imgur.com/DVrMu.jpg?s=128&g=1","display_name":"Dan","link":"http://emacs.stackexchange.com/users/253/dan"},"comments":[{"owner":{"reputation":216,"user_id":163,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/d602eadb9367e8c1a2e00c0bef73555c?s=128&d=identicon&r=PG","display_name":"dharmatech","link":"http://emacs.stackexchange.com/users/163/dharmatech"},"edited":false,"score":0,"post_type":"answer","creation_date":1414792155,"post_id":2909,"comment_id":4010,"body_markdown":"Hi Dan. The idea is that if more than one buffer is shown in a frame, via multiple windows in that frame, then no buffer will be killed, but the frame will still be deleted.","link":"http://emacs.stackexchange.com/questions/2888/kill-buffer-when-frame-is-deleted/2909#comment4010_2909","body":"Hi Dan. The idea is that if more than one buffer is shown in a frame, via multiple windows in that frame, then no buffer will be killed, but the frame will still be deleted."},{"owner":{"reputation":216,"user_id":163,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/d602eadb9367e8c1a2e00c0bef73555c?s=128&d=identicon&r=PG","display_name":"dharmatech","link":"http://emacs.stackexchange.com/users/163/dharmatech"},"edited":false,"score":0,"post_type":"answer","creation_date":1414792208,"post_id":2909,"comment_id":4011,"body_markdown":"But I could see other behaviours being useful. I.e. kill all buffers shown, as long as they aren't shown in other frames.","link":"http://emacs.stackexchange.com/questions/2888/kill-buffer-when-frame-is-deleted/2909#comment4011_2909","body":"But I could see other behaviours being useful. I.e. kill all buffers shown, as long as they aren't shown in other frames."}],"comment_count":2,"is_accepted":false,"score":5,"last_activity_date":1414761011,"creation_date":1414761011,"answer_id":2909,"question_id":2888,"body_markdown":"<!-- language: lang-el -->\r\n\r\nBelow is a function (tested, but not extensively) that meets your first requirement: it kills the current buffer when you close a frame *UNLESS* the buffer is also visible in another frame.\r\n\r\n (defun kill-buffer-when-frame-delete-dwim (frame)\r\n "Kill current buffer unless it's visible in another frame\r\n besides current FRAME."\r\n (unless (delq nil (mapcar #'(lambda (x)\r\n (memq (current-buffer)\r\n (mapcar #'window-buffer x)))\r\n (mapcar #'window-list\r\n (delq frame (frame-list)))))\r\n (kill-buffer (current-buffer))))\r\n\r\n (add-hook 'delete-frame-functions 'kill-buffer-when-frame-delete-dwim)\r\n\r\nI'm unclear on the second requirement:\r\n\r\n - By *more than one buffer displayed in the frame*, do you mean the frame has a) two or more windows, *and* b) the windows have different buffers displayed in them? \r\n - By *do nothing*, do you mean a) delete the frame but do *not* kill the current buffer, *or* b) really do nothing at all: do not delete the frame or kill the current buffer?\r\n","link":"http://emacs.stackexchange.com/questions/2888/kill-buffer-when-frame-is-deleted/2909#2909","title":"Kill buffer when frame is deleted","body":"\n\n<p>Below is a function (tested, but not extensively) that meets your first requirement: it kills the current buffer when you close a frame <em>UNLESS</em> the buffer is also visible in another frame.</p>\n\n<pre><code>(defun kill-buffer-when-frame-delete-dwim (frame)\n \"Kill current buffer unless it's visible in another frame\nbesides current FRAME.\"\n (unless (delq nil (mapcar #'(lambda (x)\n (memq (current-buffer)\n (mapcar #'window-buffer x)))\n (mapcar #'window-list\n (delq frame (frame-list)))))\n (kill-buffer (current-buffer))))\n\n(add-hook 'delete-frame-functions 'kill-buffer-when-frame-delete-dwim)\n</code></pre>\n\n<p>I'm unclear on the second requirement:</p>\n\n<ul>\n<li>By <em>more than one buffer displayed in the frame</em>, do you mean the frame has a) two or more windows, <em>and</em> b) the windows have different buffers displayed in them? </li>\n<li>By <em>do nothing</em>, do you mean a) delete the frame but do <em>not</em> kill the current buffer, <em>or</em> b) really do nothing at all: do not delete the frame or kill the current buffer?</li>\n</ul>\n"},{"owner":{"reputation":474,"user_id":780,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/e07f5643e4e9331ad5ca713c072b19f9?s=128&d=identicon&r=PG","display_name":"glucas","link":"http://emacs.stackexchange.com/users/780/glucas"},"comments":[{"owner":{"reputation":216,"user_id":163,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/d602eadb9367e8c1a2e00c0bef73555c?s=128&d=identicon&r=PG","display_name":"dharmatech","link":"http://emacs.stackexchange.com/users/163/dharmatech"},"edited":false,"score":0,"post_type":"answer","creation_date":1414792329,"post_id":2915,"comment_id":4012,"body_markdown":"Looks good. Thanks glucas!","link":"http://emacs.stackexchange.com/questions/2888/kill-buffer-when-frame-is-deleted/2915#comment4012_2915","body":"Looks good. Thanks glucas!"}],"comment_count":1,"is_accepted":true,"score":5,"last_activity_date":1414765666,"creation_date":1414765666,"answer_id":2915,"question_id":2888,"body_markdown":"If I've understood the question, here's a function that does what you want:\r\n\r\n (defun maybe-delete-frame-buffer (frame)\r\n "When a dedicated FRAME is deleted, also kill its buffer.\r\n A dedicated frame contains a single window whose buffer is not\r\n displayed anywhere else."\r\n (let ((windows (window-list frame)))\r\n (when (eq 1 (length windows))\r\n (let ((buffer (window-buffer (car windows))))\r\n \t (when (eq 1 (length (get-buffer-window-list buffer nil t)))\r\n \t (kill-buffer buffer))))))\r\n\r\nYou can add it as a hook that gets called whenever a frame is closed using:\r\n\r\n (add-to-list 'delete-frame-functions #'maybe-delete-frame-buffer)\r\n\r\n\r\n","link":"http://emacs.stackexchange.com/questions/2888/kill-buffer-when-frame-is-deleted/2915#2915","title":"Kill buffer when frame is deleted","body":"<p>If I've understood the question, here's a function that does what you want:</p>\n\n<pre><code>(defun maybe-delete-frame-buffer (frame)\n \"When a dedicated FRAME is deleted, also kill its buffer.\nA dedicated frame contains a single window whose buffer is not\ndisplayed anywhere else.\"\n (let ((windows (window-list frame)))\n (when (eq 1 (length windows))\n (let ((buffer (window-buffer (car windows))))\n (when (eq 1 (length (get-buffer-window-list buffer nil t)))\n (kill-buffer buffer))))))\n</code></pre>\n\n<p>You can add it as a hook that gets called whenever a frame is closed using:</p>\n\n<pre><code>(add-to-list 'delete-frame-functions #'maybe-delete-frame-buffer)\n</code></pre>\n"}],"tags":["buffers","frames"],"owner":{"reputation":216,"user_id":163,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/d602eadb9367e8c1a2e00c0bef73555c?s=128&d=identicon&r=PG","display_name":"dharmatech","link":"http://emacs.stackexchange.com/users/163/dharmatech"},"comment_count":0,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":57,"favorite_count":2,"accepted_answer_id":2915,"answer_count":3,"score":5,"last_activity_date":1414765666,"creation_date":1414725672,"question_id":2888,"body_markdown":"When I close a frame, I'd like for its buffer to be killed.\r\n\r\nIf the buffer is displayed in other frames, the buffer should not be killed.\r\n\r\nDo nothing if more than one buffer is displayed in a frame.\r\n\r\nWhat's a good way to set this up?","link":"http://emacs.stackexchange.com/questions/2888/kill-buffer-when-frame-is-deleted","title":"Kill buffer when frame is deleted","body":"<p>When I close a frame, I'd like for its buffer to be killed.</p>\n\n<p>If the buffer is displayed in other frames, the buffer should not be killed.</p>\n\n<p>Do nothing if more than one buffer is displayed in a frame.</p>\n\n<p>What's a good way to set this up?</p>\n"},{"answers":[{"owner":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"comments":[{"owner":{"reputation":631,"user_id":1979,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6d7d7689f9562293f6106353a6b1a905?s=128&d=identicon&r=PG","display_name":"Stefan","link":"http://emacs.stackexchange.com/users/1979/stefan"},"edited":false,"score":0,"post_type":"answer","creation_date":1414762756,"post_id":2896,"comment_id":3974,"body_markdown":"Actually, the body of a defun *is* evaluated (when the function is called) and it is macro-expanded when the function is defined. So his trick should/could work.","link":"http://emacs.stackexchange.com/questions/2887/is-there-a-better-way-to-handle-multiline-docstrings-in-elisp/2896#comment3974_2896","body":"Actually, the body of a defun <i>is</i> evaluated (when the function is called) and it is macro-expanded when the function is defined. So his trick should/could work."},{"owner":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"reply_to_user":{"reputation":631,"user_id":1979,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6d7d7689f9562293f6106353a6b1a905?s=128&d=identicon&r=PG","display_name":"Stefan","link":"http://emacs.stackexchange.com/users/1979/stefan"},"edited":false,"score":0,"post_type":"answer","creation_date":1414764266,"post_id":2896,"comment_id":3978,"body_markdown":"@Stefan That's true. Forgot `eval-when-compile` was a macro.","link":"http://emacs.stackexchange.com/questions/2887/is-there-a-better-way-to-handle-multiline-docstrings-in-elisp/2896#comment3978_2896","body":"@Stefan That's true. Forgot <code>eval-when-compile</code> was a macro."}],"last_editor":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"comment_count":2,"is_accepted":false,"score":5,"last_activity_date":1414764354,"last_edit_date":1414764354,"creation_date":1414745945,"answer_id":2896,"question_id":2887,"body_markdown":"You could use a macro like this:\r\n\r\n (defmacro my-defun (name arglist &rest forms)\r\n "Like `defun', but concatenates strings."\r\n (declare (indent defun))\r\n (let (doc-lines)\r\n (while (and (stringp (car-safe forms))\r\n (> (length forms) 1))\r\n (setq doc-lines\r\n (append doc-lines (list (pop forms)))))\r\n `(defun ,name ,arglist\r\n ,(mapconcat #'identity doc-lines "\\n")\r\n ,@forms)))\r\n \r\nThen you can define your functions like this:\r\n\r\n (my-defun test (a)\r\n "Description"\r\n "asodksad"\r\n "ok"\r\n (interactive)\r\n (+ 1 a))\r\n\r\n----------\r\n\r\nStill, I'd **strongly** recommend not going against the standards for\r\nsuch a marginal benefit. The “irregular indentation” that bothers you\r\nis just by 2 columns, not to mention it helps highlight the first line\r\nof documentation which is more important.\r\n","link":"http://emacs.stackexchange.com/questions/2887/is-there-a-better-way-to-handle-multiline-docstrings-in-elisp/2896#2896","title":"Is there a better way to handle multiline docstrings in elisp?","body":"<p>You could use a macro like this:</p>\n\n<pre><code>(defmacro my-defun (name arglist &rest forms)\n \"Like `defun', but concatenates strings.\"\n (declare (indent defun))\n (let (doc-lines)\n (while (and (stringp (car-safe forms))\n (> (length forms) 1))\n (setq doc-lines\n (append doc-lines (list (pop forms)))))\n `(defun ,name ,arglist\n ,(mapconcat #'identity doc-lines \"\\n\")\n ,@forms)))\n</code></pre>\n\n<p>Then you can define your functions like this:</p>\n\n<pre><code>(my-defun test (a)\n \"Description\"\n \"asodksad\"\n \"ok\"\n (interactive)\n (+ 1 a))\n</code></pre>\n\n<hr>\n\n<p>Still, I'd <strong>strongly</strong> recommend not going against the standards for\nsuch a marginal benefit. The “irregular indentation” that bothers you\nis just by 2 columns, not to mention it helps highlight the first line\nof documentation which is more important.</p>\n"},{"owner":{"reputation":1487,"user_id":160,"user_type":"registered","profile_image":"http://i.stack.imgur.com/y27jq.png?s=128&g=1","display_name":"Jordon Biondo","link":"http://emacs.stackexchange.com/users/160/jordon-biondo"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414762322,"creation_date":1414762322,"answer_id":2911,"question_id":2887,"body_markdown":"I've seen packages that define docstrings like this:\r\n\r\n\r\n (defun my-function (x y) "\r\n this is my docstring\r\n that lines always lines up\r\n across multiple lines."\r\n (+ x y))\r\n\r\nPlacing the first quote on the first line then starting the text on the next so they all line up. It's definitely not the standard but you wouldn't be the only one doing it.","link":"http://emacs.stackexchange.com/questions/2887/is-there-a-better-way-to-handle-multiline-docstrings-in-elisp/2911#2911","title":"Is there a better way to handle multiline docstrings in elisp?","body":"<p>I've seen packages that define docstrings like this:</p>\n\n<pre><code>(defun my-function (x y) \"\nthis is my docstring\nthat lines always lines up\nacross multiple lines.\"\n (+ x y))\n</code></pre>\n\n<p>Placing the first quote on the first line then starting the text on the next so they all line up. It's definitely not the standard but you wouldn't be the only one doing it.</p>\n"},{"owner":{"reputation":631,"user_id":1979,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6d7d7689f9562293f6106353a6b1a905?s=128&d=identicon&r=PG","display_name":"Stefan","link":"http://emacs.stackexchange.com/users/1979/stefan"},"comments":[{"owner":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":0,"post_type":"answer","creation_date":1414765927,"post_id":2912,"comment_id":3982,"body_markdown":"I really like your second solution. But my irrational fear of advices makes me hinge at the first. :-)","link":"http://emacs.stackexchange.com/questions/2887/is-there-a-better-way-to-handle-multiline-docstrings-in-elisp/2912#comment3982_2912","body":"I really like your second solution. But my irrational fear of advices makes me hinge at the first. :-)"}],"last_editor":{"reputation":631,"user_id":1979,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6d7d7689f9562293f6106353a6b1a905?s=128&d=identicon&r=PG","display_name":"Stefan","link":"http://emacs.stackexchange.com/users/1979/stefan"},"comment_count":1,"is_accepted":false,"score":5,"last_activity_date":1414763166,"last_edit_date":1414763166,"creation_date":1414762336,"answer_id":2912,"question_id":2887,"body_markdown":"Of course a `my-defun` macro is the easy way out.\r\nBut a simpler solution would be\r\n\r\n (advice-add 'eval-when-compile :filter-return\r\n (lambda (exp)\r\n (if (and (eq 'quote (car-safe exp))\r\n (stringp (cadr exp)))\r\n (cadr exp)\r\n exp)))\r\n\r\nWhich should make your trick work, at least in all the cases where the function is macroexpanded before it's actually defined, which should include the main use cases (e.g. if it'sloaded from a file, if it's byte-compiled, or if it's defined via `M-C-x`).\r\n\r\nStill, this won't fix all the existing code, so maybe a better answer is something like:\r\n\r\n ;; -*- lexical-binding:t -*-\r\n\r\n (defun my-shift-docstrings (orig ppss)\r\n (let ((face (funcall orig ppss)))\r\n (when (eq face 'font-lock-doc-face)\r\n (save-excursion\r\n (let ((start (point)))\r\n (parse-partial-sexp (point) (point-max) nil nil ppss 'syntax-table)\r\n (while (search-backward "\\n" start t)\r\n (put-text-property (point) (1+ (point)) 'display\r\n (propertize "\\n " 'cursor 0))))))\r\n face))\r\n\r\n (add-hook 'emacs-lisp-mode-hook\r\n (lambda ()\r\n (font-lock-mode 1)\r\n\t (push 'display font-lock-extra-managed-props)\r\n (add-function :around (local 'font-lock-syntactic-face-function)\r\n #'my-shift-docstrings)))\r\n\r\nwhich should just shift the docstrings by 2 spaces, but only on the display side, without affecting the buffer's actual content.","link":"http://emacs.stackexchange.com/questions/2887/is-there-a-better-way-to-handle-multiline-docstrings-in-elisp/2912#2912","title":"Is there a better way to handle multiline docstrings in elisp?","body":"<p>Of course a <code>my-defun</code> macro is the easy way out.\nBut a simpler solution would be</p>\n\n<pre><code>(advice-add 'eval-when-compile :filter-return\n (lambda (exp)\n (if (and (eq 'quote (car-safe exp))\n (stringp (cadr exp)))\n (cadr exp)\n exp)))\n</code></pre>\n\n<p>Which should make your trick work, at least in all the cases where the function is macroexpanded before it's actually defined, which should include the main use cases (e.g. if it'sloaded from a file, if it's byte-compiled, or if it's defined via <code>M-C-x</code>).</p>\n\n<p>Still, this won't fix all the existing code, so maybe a better answer is something like:</p>\n\n<pre><code>;; -*- lexical-binding:t -*-\n\n(defun my-shift-docstrings (orig ppss)\n (let ((face (funcall orig ppss)))\n (when (eq face 'font-lock-doc-face)\n (save-excursion\n (let ((start (point)))\n (parse-partial-sexp (point) (point-max) nil nil ppss 'syntax-table)\n (while (search-backward \"\\n\" start t)\n (put-text-property (point) (1+ (point)) 'display\n (propertize \"\\n \" 'cursor 0))))))\n face))\n\n(add-hook 'emacs-lisp-mode-hook\n (lambda ()\n (font-lock-mode 1)\n (push 'display font-lock-extra-managed-props)\n (add-function :around (local 'font-lock-syntactic-face-function)\n #'my-shift-docstrings)))\n</code></pre>\n\n<p>which should just shift the docstrings by 2 spaces, but only on the display side, without affecting the buffer's actual content.</p>\n"}],"tags":["elisp","documentation"],"owner":{"reputation":131,"user_id":2345,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b37fdf7928b7aecd15a973b250979333?s=128&d=identicon&r=PG","display_name":"Krazy Glew","link":"http://emacs.stackexchange.com/users/2345/krazy-glew"},"comments":[{"owner":{"reputation":131,"user_id":962,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/48c64077a6536acf7070b86eb4f02aca?s=128&d=identicon&r=PG","display_name":"Harald Hanche-Olsen","link":"http://emacs.stackexchange.com/users/962/harald-hanche-olsen"},"edited":false,"score":0,"post_type":"question","creation_date":1414745364,"post_id":2887,"comment_id":3947,"body_markdown":"It should be fairly easy to create a macro that will expand into a `defun`. The drawback to that approach – and it is a big one – is that will confuse any software (other than the elisp compiler/interpreter) that is parsing your code looking for `defun`s.","link":"http://emacs.stackexchange.com/questions/2887/is-there-a-better-way-to-handle-multiline-docstrings-in-elisp#comment3947_2887","body":"It should be fairly easy to create a macro that will expand into a <code>defun</code>. The drawback to that approach – and it is a big one – is that will confuse any software (other than the elisp compiler/interpreter) that is parsing your code looking for <code>defun</code>s."},{"owner":{"reputation":631,"user_id":1979,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6d7d7689f9562293f6106353a6b1a905?s=128&d=identicon&r=PG","display_name":"Stefan","link":"http://emacs.stackexchange.com/users/1979/stefan"},"edited":false,"score":0,"post_type":"question","creation_date":1414762664,"post_id":2887,"comment_id":3972,"body_markdown":"Funnily enough, the reason why your trick doesn't work is that `eval-when-compile` quotes its result (to turn it from a value to an expression). If it were a bit more clever and only quoted its result when it's not self-quoting, it would work.","link":"http://emacs.stackexchange.com/questions/2887/is-there-a-better-way-to-handle-multiline-docstrings-in-elisp#comment3972_2887","body":"Funnily enough, the reason why your trick doesn't work is that <code>eval-when-compile</code> quotes its result (to turn it from a value to an expression). If it were a bit more clever and only quoted its result when it's not self-quoting, it would work."}],"last_editor":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"comment_count":2,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":100,"favorite_count":1,"answer_count":3,"score":6,"last_activity_date":1414764354,"creation_date":1414725439,"last_edit_date":1414741213,"question_id":2887,"body_markdown":"I hate the way that elisp (not sure if LISP in general) handles multiline docstrings.\r\n\r\n (defun foo ()\r\n "This is\r\n a multi\r\n liner\r\n docstring"\r\n (do-stuff))\r\n\r\n\r\nI sure do wish that I could do something like\r\n\r\n (defun foo ()\r\n (eval-when-compile \r\n (concat\r\n "This is\\n"\r\n "a multi\\n"\r\n "line\\n"\r\n "docstring"))\r\n (do-stuff))\r\n\r\nso that the indentation was consistent.\r\n\r\nUnfortunately, eval-when-compile does not do the job.\r\n\r\nDoes anyone have any ideas?\r\n\r\n","link":"http://emacs.stackexchange.com/questions/2887/is-there-a-better-way-to-handle-multiline-docstrings-in-elisp","title":"Is there a better way to handle multiline docstrings in elisp?","body":"<p>I hate the way that elisp (not sure if LISP in general) handles multiline docstrings.</p>\n\n<pre><code>(defun foo ()\n \"This is\na multi\nliner\ndocstring\"\n (do-stuff))\n</code></pre>\n\n<p>I sure do wish that I could do something like</p>\n\n<pre><code>(defun foo ()\n (eval-when-compile \n (concat\n \"This is\\n\"\n \"a multi\\n\"\n \"line\\n\"\n \"docstring\"))\n (do-stuff))\n</code></pre>\n\n<p>so that the indentation was consistent.</p>\n\n<p>Unfortunately, eval-when-compile does not do the job.</p>\n\n<p>Does anyone have any ideas?</p>\n"},{"answers":[{"owner":{"reputation":853,"user_id":2005,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1fd94c0bb560b4445acb97f05b0e9a81?s=128&d=identicon&r=PG","display_name":"rekado","link":"http://emacs.stackexchange.com/users/2005/rekado"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414761822,"creation_date":1414761822,"answer_id":2910,"question_id":2903,"body_markdown":"I now use this:\r\n\r\n (defun original-god-mode-lookup-key-sequence (&optional key key-string-so-far) ())\r\n (fset 'original-god-mode-lookup-key-sequence (symbol-function 'god-mode-lookup-key-sequence))\r\n \r\n (defun god-mode-lookup-key-sequence (&optional key key-string-so-far)\r\n "Wrap original-god-mode-lookup-key-sequence. Swap x and t."\r\n (interactive)\r\n (case key\r\n (?x (original-god-mode-lookup-key-sequence ?t key-string-so-far))\r\n (?t (original-god-mode-lookup-key-sequence ?x key-string-so-far))\r\n (t (original-god-mode-lookup-key-sequence key key-string-so-far))))\r\n\r\nIt makes a copy of `god-mode-lookup-key-sequence` as `original-god-mode-lookup-key-sequence` and then overrides it with a wrapper that performs the swap for `x` and `t`. It's not elegant, but at least it won't leak.","link":"http://emacs.stackexchange.com/questions/2903/god-mode-swap-keys/2910#2910","title":"god-mode: swap keys","body":"<p>I now use this:</p>\n\n<pre><code>(defun original-god-mode-lookup-key-sequence (&optional key key-string-so-far) ())\n(fset 'original-god-mode-lookup-key-sequence (symbol-function 'god-mode-lookup-key-sequence))\n\n(defun god-mode-lookup-key-sequence (&optional key key-string-so-far)\n \"Wrap original-god-mode-lookup-key-sequence. Swap x and t.\"\n (interactive)\n (case key\n (?x (original-god-mode-lookup-key-sequence ?t key-string-so-far))\n (?t (original-god-mode-lookup-key-sequence ?x key-string-so-far))\n (t (original-god-mode-lookup-key-sequence key key-string-so-far))))\n</code></pre>\n\n<p>It makes a copy of <code>god-mode-lookup-key-sequence</code> as <code>original-god-mode-lookup-key-sequence</code> and then overrides it with a wrapper that performs the swap for <code>x</code> and <code>t</code>. It's not elegant, but at least it won't leak.</p>\n"}],"tags":["key-bindings","keymap","god-mode"],"owner":{"reputation":853,"user_id":2005,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1fd94c0bb560b4445acb97f05b0e9a81?s=128&d=identicon&r=PG","display_name":"rekado","link":"http://emacs.stackexchange.com/users/2005/rekado"},"comment_count":0,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":false,"view_count":27,"favorite_count":0,"answer_count":1,"score":2,"last_activity_date":1414761822,"creation_date":1414755674,"question_id":2903,"body_markdown":"I'm using the Dvorak keyboard layout and have swapped `C-x` and `C-t`, because I find it easier to type on Dvorak.\r\n\r\n (define-key key-translation-map [?\\C-x] [?\\C-t])\r\n (define-key key-translation-map [?\\C-t] [?\\C-x])\r\n\r\nI'm also using `god-mode`, though, so I'd like `x` to be swapped with `t` when in `god-local-mode`, such that typing `x` results in `C-t` and typing `t` results in `C-x`. I have a very crude solution using `keyboard-translate`:\r\n\r\n (defun my-god-swap-on ()\r\n (interactive)\r\n (keyboard-translate ?x ?t)\r\n (keyboard-translate ?t ?x))\r\n \r\n (defun my-god-swap-off ()\r\n (interactive)\r\n (aset keyboard-translate-table ?t nil)\r\n (aset keyboard-translate-table ?x nil))\r\n \r\n (add-hook 'god-mode-enabled-hook 'my-god-swap-on)\r\n (add-hook 'god-mode-disabled-hook 'my-god-swap-off)\r\n\r\nAlthough this works it is extremely inelegant as it modifies global state. If I switched to a buffer where god-mode is not enabled, the translation would still be active. I could add yet another hook for buffer switching to make sure that the translation is disabled when `god-local-mode` is inactive in the current buffer, but this seems like a very ugly mitigation technique.\r\n\r\nIs it possible to restrict the effects to a keyboard translation to only a single minor mode?\r\n\r\nIf this is not possible, is there another more elegant way I could swap keys in `god-mode`? I see that `god-mode` rewires all keys bound to `self-insert-command` to `god-mode-self-insert`, but this uses `this-command-keys-vector` to determine with what key it was called and I cannot seem to shadow the definition of `this-command-keys-vector` with a let binding to swap `x` and `t` in a wrapper before passing control to `god-mode-self-insert`.","link":"http://emacs.stackexchange.com/questions/2903/god-mode-swap-keys","title":"god-mode: swap keys","body":"<p>I'm using the Dvorak keyboard layout and have swapped <code>C-x</code> and <code>C-t</code>, because I find it easier to type on Dvorak.</p>\n\n<pre><code>(define-key key-translation-map [?\\C-x] [?\\C-t])\n(define-key key-translation-map [?\\C-t] [?\\C-x])\n</code></pre>\n\n<p>I'm also using <code>god-mode</code>, though, so I'd like <code>x</code> to be swapped with <code>t</code> when in <code>god-local-mode</code>, such that typing <code>x</code> results in <code>C-t</code> and typing <code>t</code> results in <code>C-x</code>. I have a very crude solution using <code>keyboard-translate</code>:</p>\n\n<pre><code>(defun my-god-swap-on ()\n (interactive)\n (keyboard-translate ?x ?t)\n (keyboard-translate ?t ?x))\n\n(defun my-god-swap-off ()\n (interactive)\n (aset keyboard-translate-table ?t nil)\n (aset keyboard-translate-table ?x nil))\n\n(add-hook 'god-mode-enabled-hook 'my-god-swap-on)\n(add-hook 'god-mode-disabled-hook 'my-god-swap-off)\n</code></pre>\n\n<p>Although this works it is extremely inelegant as it modifies global state. If I switched to a buffer where god-mode is not enabled, the translation would still be active. I could add yet another hook for buffer switching to make sure that the translation is disabled when <code>god-local-mode</code> is inactive in the current buffer, but this seems like a very ugly mitigation technique.</p>\n\n<p>Is it possible to restrict the effects to a keyboard translation to only a single minor mode?</p>\n\n<p>If this is not possible, is there another more elegant way I could swap keys in <code>god-mode</code>? I see that <code>god-mode</code> rewires all keys bound to <code>self-insert-command</code> to <code>god-mode-self-insert</code>, but this uses <code>this-command-keys-vector</code> to determine with what key it was called and I cannot seem to shadow the definition of <code>this-command-keys-vector</code> with a let binding to swap <code>x</code> and <code>t</code> in a wrapper before passing control to <code>god-mode-self-insert</code>.</p>\n"},{"tags":["indentation"],"owner":{"reputation":81,"user_id":2305,"user_type":"registered","profile_image":"http://i.stack.imgur.com/qkoVH.jpg?s=128&g=1","display_name":"Vivian Maya","link":"http://emacs.stackexchange.com/users/2305/vivian-maya"},"comments":[{"owner":{"reputation":2563,"user_id":115,"user_type":"registered","accept_rate":88,"profile_image":"https://www.gravatar.com/avatar/6dbe470c7ef3817bb1da85dc5883acbe?s=128&d=identicon&r=PG","display_name":"kaushalmodi","link":"http://emacs.stackexchange.com/users/115/kaushalmodi"},"edited":false,"score":0,"post_type":"question","creation_date":1414757555,"post_id":2904,"comment_id":3958,"body_markdown":"Are you talking about using TAB to move to next field when inserting a yasnippet template?","link":"http://emacs.stackexchange.com/questions/2904/tab-does-not-auto-indent-lines-anymore#comment3958_2904","body":"Are you talking about using TAB to move to next field when inserting a yasnippet template?"},{"owner":{"reputation":2563,"user_id":115,"user_type":"registered","accept_rate":88,"profile_image":"https://www.gravatar.com/avatar/6dbe470c7ef3817bb1da85dc5883acbe?s=128&d=identicon&r=PG","display_name":"kaushalmodi","link":"http://emacs.stackexchange.com/users/115/kaushalmodi"},"edited":false,"score":1,"post_type":"question","creation_date":1414757716,"post_id":2904,"comment_id":3959,"body_markdown":"Or are you asking how to use TAB for template insertion instead of auto completion?","link":"http://emacs.stackexchange.com/questions/2904/tab-does-not-auto-indent-lines-anymore#comment3959_2904","body":"Or are you asking how to use TAB for template insertion instead of auto completion?"},{"owner":{"reputation":81,"user_id":2305,"user_type":"registered","profile_image":"http://i.stack.imgur.com/qkoVH.jpg?s=128&g=1","display_name":"Vivian Maya","link":"http://emacs.stackexchange.com/users/2305/vivian-maya"},"reply_to_user":{"reputation":2563,"user_id":115,"user_type":"registered","accept_rate":88,"profile_image":"https://www.gravatar.com/avatar/6dbe470c7ef3817bb1da85dc5883acbe?s=128&d=identicon&r=PG","display_name":"kaushalmodi","link":"http://emacs.stackexchange.com/users/115/kaushalmodi"},"edited":false,"score":0,"post_type":"question","creation_date":1414758099,"post_id":2904,"comment_id":3960,"body_markdown":"second one, my TAB button is doing just complete things, I do not have any problem with yasnippet or auto-complete.","link":"http://emacs.stackexchange.com/questions/2904/tab-does-not-auto-indent-lines-anymore#comment3960_2904","body":"second one, my TAB button is doing just complete things, I do not have any problem with yasnippet or auto-complete."},{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":1,"post_type":"question","creation_date":1414760198,"post_id":2904,"comment_id":3962,"body_markdown":"Bind TAB to one thing only, and should be used for auto-complete. It would be easier. You can bind RET to `newline-and-indent` for automatic indentation: `(global-set-key (kbd "RET") 'newline-and-indent)`. You can indent whole buffer or region (if selected) using the code snippet [here](http://emacsredux.com/blog/2013/03/27/indent-region-or-buffer/).","link":"http://emacs.stackexchange.com/questions/2904/tab-does-not-auto-indent-lines-anymore#comment3962_2904","body":"Bind TAB to one thing only, and should be used for auto-complete. It would be easier. You can bind RET to <code>newline-and-indent</code> for automatic indentation: <code>(global-set-key (kbd "RET") 'newline-and-indent)</code>. You can indent whole buffer or region (if selected) using the code snippet <a href=\"http://emacsredux.com/blog/2013/03/27/indent-region-or-buffer/\" rel=\"nofollow\">here</a>."},{"owner":{"reputation":81,"user_id":2305,"user_type":"registered","profile_image":"http://i.stack.imgur.com/qkoVH.jpg?s=128&g=1","display_name":"Vivian Maya","link":"http://emacs.stackexchange.com/users/2305/vivian-maya"},"reply_to_user":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414760405,"post_id":2904,"comment_id":3963,"body_markdown":"@TuDo Could you look at my edit, how can i enable y auto-complete for jde,it doesn't work when I coding java.","link":"http://emacs.stackexchange.com/questions/2904/tab-does-not-auto-indent-lines-anymore#comment3963_2904","body":"@TuDo Could you look at my edit, how can i enable y auto-complete for jde,it doesn't work when I coding java."},{"owner":{"reputation":2563,"user_id":115,"user_type":"registered","accept_rate":88,"profile_image":"https://www.gravatar.com/avatar/6dbe470c7ef3817bb1da85dc5883acbe?s=128&d=identicon&r=PG","display_name":"kaushalmodi","link":"http://emacs.stackexchange.com/users/115/kaushalmodi"},"edited":false,"score":0,"post_type":"question","creation_date":1414760513,"post_id":2904,"comment_id":3964,"body_markdown":"@VivianMaya Feel free to revert to your original question if I have misunderstood what you meant. I have reworded the question title and content.","link":"http://emacs.stackexchange.com/questions/2904/tab-does-not-auto-indent-lines-anymore#comment3964_2904","body":"@VivianMaya Feel free to revert to your original question if I have misunderstood what you meant. I have reworded the question title and content."}],"last_editor":{"reputation":2563,"user_id":115,"user_type":"registered","accept_rate":88,"profile_image":"https://www.gravatar.com/avatar/6dbe470c7ef3817bb1da85dc5883acbe?s=128&d=identicon&r=PG","display_name":"kaushalmodi","link":"http://emacs.stackexchange.com/users/115/kaushalmodi"},"comment_count":6,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":false,"view_count":27,"favorite_count":0,"answer_count":0,"score":1,"last_activity_date":1414760438,"creation_date":1414757159,"last_edit_date":1414760438,"question_id":2904,"body_markdown":"I used to have a configuration for <kbd>TAB</kbd> which was doing something like this :\r\n\r\nThis is the code before hitting <kbd>TAB</kbd>.\r\n\r\n template<typename T>\r\n class A\r\n {\r\n \r\n }; // This is where I hit TAB\r\n \r\nThe code auto-indented as below after hitting <kbd>TAB</kbd>:\r\n\r\n template<typename T>\r\n class A\r\n {\r\n \r\n };\r\n\r\nThe <kbd>TAB</kbd> key used to work as above but now it does only auto-complete.\r\n\r\nCan I fix this ? I can use <kbd>TAB</kbd> with <kbd>C-q</kbd><kbd>TAB</kbd> but it is hard to do always. \r\n\r\nHere is my .emacs file\r\n\r\n (add-to-list 'load-path "~/.emacs.d/jdee-2.4.1/lisp")\r\n (load "jde")\r\n \r\n (add-to-list 'load-path "~/.emacs.d")\r\n (require 'linum)\r\n (global-linum-mode 1)\r\n \r\n (add-to-list 'load-path "~/.emacs.d/elpa/yasnippet-0.8.0")\r\n (require 'yasnippet)\r\n (yas-global-mode 1)\r\n ; care about this place\r\n (define-key yas-minor-mode-map (kbd "<tab>") nil)\r\n (define-key yas-minor-mode-map (kbd "TAB") nil)\r\n (define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)\r\n ; care about this place\r\n (setq ac-source-yasnippet nil)\r\n \r\n \r\n (add-to-list 'load-path "~/.emacs.d/auto-complete-1.3.1")\r\n (require 'auto-complete-config)\r\n (ac-config-default)\r\n (add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")\r\n (global-auto-complete-mode t) ; section1\r\n (ac-set-trigger-key "TAB")\r\n (ac-set-trigger-key "<tab>")\r\n \r\n (defun my:ac-c-headers-init ()\r\n (require 'auto-complete-c-headers)\r\n (add-to-list 'ac-sources 'ac-source-c-headers))\r\n \r\n (add-hook 'c++-mode-hook 'my:ac-c-headers-init)\r\n (add-hook 'c-mode-hook 'my:ac-c-headers-init)\r\n \r\n (add-to-list 'load-path "~/.emacs.d/iedit")\r\n (require 'iedit)\r\n (define-key global-map (kbd "C-c ;") 'iedit-mode)\r\n \r\n (semantic-mode 1)\r\n (defun my:add-semantic-to-autocomplete() \r\n (add-to-list 'ac-sources 'ac-source-semantic)\r\n )\r\n (add-hook 'c-mode-common-hook 'my:add-semantic-to-autocomplete)\r\n (custom-set-variables\r\n ;; custom-set-variables was added by Custom.\r\n ;; If you edit it by hand, you could mess it up, so be careful.\r\n ;; Your init file should contain only one such instance.\r\n ;; If there is more than one, they won't work right.\r\n '(ansi-color-names-vector ["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"])\r\n '(cua-mode t nil (cua-base))\r\n '(custom-enabled-themes (quote (tango-dark)))\r\n '(font-use-system-font t)\r\n '(show-paren-mode t)\r\n '(uniquify-buffer-name-style (quote forward) nil (uniquify)))\r\n (custom-set-faces\r\n ;; custom-set-faces was added by Custom.\r\n ;; If you edit it by hand, you could mess it up, so be careful.\r\n ;; Your init file should contain only one such instance.\r\n ;; If there is more than one, they won't work right.\r\n '(default ((t (:family "DejaVu Sans Mono" :foundry "unknown" :slant normal :weight bold :height 113 :width normal)))))\r\n (setq-default indent-tabs-mode nil)\r\n (setq-default tab-width 2)\r\n (setq indent-line-function 'insert-tab)\r\n\r\n**Edit** When I add JDE it fixed but now I cannot use auto-complete ? It doesn't complete anything.\r\n","link":"http://emacs.stackexchange.com/questions/2904/tab-does-not-auto-indent-lines-anymore","title":"TAB does not auto-indent lines anymore","body":"<p>I used to have a configuration for <kbd>TAB</kbd> which was doing something like this :</p>\n\n<p>This is the code before hitting <kbd>TAB</kbd>.</p>\n\n<pre><code>template<typename T>\nclass A\n{\n\n }; // This is where I hit TAB\n</code></pre>\n\n<p>The code auto-indented as below after hitting <kbd>TAB</kbd>:</p>\n\n<pre><code>template<typename T>\nclass A\n{\n\n};\n</code></pre>\n\n<p>The <kbd>TAB</kbd> key used to work as above but now it does only auto-complete.</p>\n\n<p>Can I fix this ? I can use <kbd>TAB</kbd> with <kbd>C-q</kbd><kbd>TAB</kbd> but it is hard to do always. </p>\n\n<p>Here is my .emacs file</p>\n\n<pre><code>(add-to-list 'load-path \"~/.emacs.d/jdee-2.4.1/lisp\")\n(load \"jde\")\n\n(add-to-list 'load-path \"~/.emacs.d\")\n(require 'linum)\n(global-linum-mode 1)\n\n(add-to-list 'load-path \"~/.emacs.d/elpa/yasnippet-0.8.0\")\n(require 'yasnippet)\n(yas-global-mode 1)\n; care about this place\n(define-key yas-minor-mode-map (kbd \"<tab>\") nil)\n(define-key yas-minor-mode-map (kbd \"TAB\") nil)\n(define-key yas-minor-mode-map (kbd \"<backtab>\") 'yas-expand)\n; care about this place\n(setq ac-source-yasnippet nil)\n\n\n(add-to-list 'load-path \"~/.emacs.d/auto-complete-1.3.1\")\n(require 'auto-complete-config)\n(ac-config-default)\n(add-to-list 'ac-dictionary-directories \"~/.emacs.d/ac-dict\")\n(global-auto-complete-mode t) ; section1\n(ac-set-trigger-key \"TAB\")\n(ac-set-trigger-key \"<tab>\")\n\n(defun my:ac-c-headers-init ()\n (require 'auto-complete-c-headers)\n (add-to-list 'ac-sources 'ac-source-c-headers))\n\n(add-hook 'c++-mode-hook 'my:ac-c-headers-init)\n(add-hook 'c-mode-hook 'my:ac-c-headers-init)\n\n(add-to-list 'load-path \"~/.emacs.d/iedit\")\n(require 'iedit)\n(define-key global-map (kbd \"C-c ;\") 'iedit-mode)\n\n(semantic-mode 1)\n(defun my:add-semantic-to-autocomplete() \n (add-to-list 'ac-sources 'ac-source-semantic)\n)\n(add-hook 'c-mode-common-hook 'my:add-semantic-to-autocomplete)\n(custom-set-variables\n ;; custom-set-variables was added by Custom.\n ;; If you edit it by hand, you could mess it up, so be careful.\n ;; Your init file should contain only one such instance.\n ;; If there is more than one, they won't work right.\n '(ansi-color-names-vector [\"#242424\" \"#e5786d\" \"#95e454\" \"#cae682\" \"#8ac6f2\" \"#333366\" \"#ccaa8f\" \"#f6f3e8\"])\n '(cua-mode t nil (cua-base))\n '(custom-enabled-themes (quote (tango-dark)))\n '(font-use-system-font t)\n '(show-paren-mode t)\n '(uniquify-buffer-name-style (quote forward) nil (uniquify)))\n(custom-set-faces\n ;; custom-set-faces was added by Custom.\n ;; If you edit it by hand, you could mess it up, so be careful.\n ;; Your init file should contain only one such instance.\n ;; If there is more than one, they won't work right.\n '(default ((t (:family \"DejaVu Sans Mono\" :foundry \"unknown\" :slant normal :weight bold :height 113 :width normal)))))\n(setq-default indent-tabs-mode nil)\n(setq-default tab-width 2)\n(setq indent-line-function 'insert-tab)\n</code></pre>\n\n<p><strong>Edit</strong> When I add JDE it fixed but now I cannot use auto-complete ? It doesn't complete anything.</p>\n"},{"answers":[{"owner":{"reputation":428,"user_id":129,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/2a1ad379159a4f4eaf5b54c5dbfe235a?s=128&d=identicon&r=PG","display_name":"stsquad","link":"http://emacs.stackexchange.com/users/129/stsquad"},"comment_count":0,"is_accepted":false,"score":3,"last_activity_date":1414760173,"creation_date":1414760173,"answer_id":2908,"question_id":2902,"body_markdown":"I use a simple password manager called [pass](http://www.passwordstore.org/). It offers a simple command line interface with is ideal for integrating with Emacs. The backing store is a GPG encrypted GIT repo. It actually ships with an [Emacs package](http://git.zx2c4.com/password-store/tree/contrib/emacs/password-store.el) although I don't use it. My interface is laughably simple:\r\n\r\n (defun my-fixup-gpg-agent (frame)\r\n "Tweak DISPLAY and GPG_TTY environment variables as appropriate to `FRAME'."\r\n (when (fboundp 'keychain-refresh-environment)\r\n (keychain-refresh-environment))\r\n (if (display-graphic-p frame)\r\n (setenv "DISPLAY" (terminal-name frame))\r\n (setenv "GPG_TTY" (terminal-name frame))\r\n (setenv "DISPLAY" nil)))\r\n\r\n (add-hook 'after-make-frame-functions 'my-fixup-gpg-agent)\r\n\r\n ;; Simple caching\r\n (defvar my-cached-passwords\r\n nil\r\n "Cache of passwords. Stored in plain text so you only want to cache\r\n them if of low value.")\r\n\r\n (defun my-pass-password (pass-name &optional cache)\r\n "Return the password for the `PASS-NAME'."\r\n (let ((cached-pass (assoc-default pass-name my-cached-passwords)))\r\n (if cached-pass\r\n cached-pass\r\n (when (selected-frame)\r\n (my-fixup-gpg-agent (selected-frame))\r\n (let ((new-pass (chomp\r\n (shell-command-to-string\r\n (format "pass %s" pass-name)))))\r\n (when (and new-pass cache)\r\n (add-to-list 'my-cached-passwords (cons pass-name new-pass)))\r\n new-pass)))))","link":"http://emacs.stackexchange.com/questions/2902/password-key-management-for-multiple-machines-in-emacs/2908#2908","title":"Password/Key Management for multiple machines in emacs","body":"<p>I use a simple password manager called <a href=\"http://www.passwordstore.org/\" rel=\"nofollow\">pass</a>. It offers a simple command line interface with is ideal for integrating with Emacs. The backing store is a GPG encrypted GIT repo. It actually ships with an <a href=\"http://git.zx2c4.com/password-store/tree/contrib/emacs/password-store.el\" rel=\"nofollow\">Emacs package</a> although I don't use it. My interface is laughably simple:</p>\n\n<pre><code>(defun my-fixup-gpg-agent (frame)\n \"Tweak DISPLAY and GPG_TTY environment variables as appropriate to `FRAME'.\"\n (when (fboundp 'keychain-refresh-environment)\n (keychain-refresh-environment))\n (if (display-graphic-p frame)\n (setenv \"DISPLAY\" (terminal-name frame))\n (setenv \"GPG_TTY\" (terminal-name frame))\n (setenv \"DISPLAY\" nil)))\n\n(add-hook 'after-make-frame-functions 'my-fixup-gpg-agent)\n\n;; Simple caching\n(defvar my-cached-passwords\n nil\n \"Cache of passwords. Stored in plain text so you only want to cache\n them if of low value.\")\n\n(defun my-pass-password (pass-name &optional cache)\n \"Return the password for the `PASS-NAME'.\"\n (let ((cached-pass (assoc-default pass-name my-cached-passwords)))\n (if cached-pass\n cached-pass\n (when (selected-frame)\n (my-fixup-gpg-agent (selected-frame))\n (let ((new-pass (chomp\n (shell-command-to-string\n (format \"pass %s\" pass-name)))))\n (when (and new-pass cache)\n (add-to-list 'my-cached-passwords (cons pass-name new-pass)))\n new-pass)))))\n</code></pre>\n"}],"tags":["tramp"],"owner":{"reputation":175,"user_id":294,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/009a0dc9a1e798678bb8a8bf9f4b6817?s=128&d=identicon&r=PG","display_name":"Gambo","link":"http://emacs.stackexchange.com/users/294/gambo"},"comment_count":0,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":60,"favorite_count":0,"answer_count":1,"score":7,"last_activity_date":1414760173,"creation_date":1414755561,"question_id":2902,"body_markdown":"I log into numerous machines as part of my job (+- 20 per day). I only spend a few days/weeks with each machine. Many run ftp only.\r\n\r\nFor seamless access Tramp is amazing, but it is the *managing* of these server's access by hand that has become tedious. \r\n\r\nI manage a .netrc and a .ssh/config by hand, along with any keys. Often a password/key will change during my time with the machine, and I will have to re-edit the files.\r\n\r\nIs there an effective solution for managing (machines/passwords/keys) from within emacs?\r\n","link":"http://emacs.stackexchange.com/questions/2902/password-key-management-for-multiple-machines-in-emacs","title":"Password/Key Management for multiple machines in emacs","body":"<p>I log into numerous machines as part of my job (+- 20 per day). I only spend a few days/weeks with each machine. Many run ftp only.</p>\n\n<p>For seamless access Tramp is amazing, but it is the <em>managing</em> of these server's access by hand that has become tedious. </p>\n\n<p>I manage a .netrc and a .ssh/config by hand, along with any keys. Often a password/key will change during my time with the machine, and I will have to re-edit the files.</p>\n\n<p>Is there an effective solution for managing (machines/passwords/keys) from within emacs?</p>\n"},{"answers":[{"owner":{"reputation":425,"user_id":2223,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/8b728c7d6c1dce81f5a82249b7617756?s=128&d=identicon&r=PG&f=1","display_name":"jch","link":"http://emacs.stackexchange.com/users/2223/jch"},"comments":[{"owner":{"reputation":13,"user_id":2342,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/8910de37dfedaf187c4b39005b809bdf?s=128&d=identicon&r=PG","display_name":"cg433n","link":"http://emacs.stackexchange.com/users/2342/cg433n"},"edited":false,"score":0,"post_type":"answer","creation_date":1414770635,"post_id":2866,"comment_id":3991,"body_markdown":"The dev seems to be aware of the issue: [ejmr/php-mode#202](https://github.com/ejmr/php-mode/issues/202)","link":"http://emacs.stackexchange.com/questions/2864/symbols-function-definition-is-void-cl-macroexpand-all-when-trying-to-instal/2866#comment3991_2866","body":"The dev seems to be aware of the issue: <a href=\"https://github.com/ejmr/php-mode/issues/202\" rel=\"nofollow\">ejmr/php-mode#202</a>"}],"comment_count":1,"is_accepted":true,"score":2,"last_activity_date":1414701270,"creation_date":1414701270,"answer_id":2866,"question_id":2864,"body_markdown":"The function `cl-macroexpand-all` has been obsoleted in Emacs 24.3; you are now supposed to use `macroexpand-all` instead, which is part of core Emacs, not the CL library.\r\n\r\nThe CL library defines `cl-macroexpand-all` as an alias for `macroexpand-all`, so in principle you could do\r\n\r\n (require 'cl)\r\n\r\nin your init file to fix the problem. However, the `cl` library itself is being deprecated, and using it is not recommended.\r\n\r\nI think you should contact the authors of `php-mode` and tell them to use `macroexpand-all`.","link":"http://emacs.stackexchange.com/questions/2864/symbols-function-definition-is-void-cl-macroexpand-all-when-trying-to-instal/2866#2866","title":""Symbol's function definition is void: cl-macroexpand-all" when trying to install php-mode","body":"<p>The function <code>cl-macroexpand-all</code> has been obsoleted in Emacs 24.3; you are now supposed to use <code>macroexpand-all</code> instead, which is part of core Emacs, not the CL library.</p>\n\n<p>The CL library defines <code>cl-macroexpand-all</code> as an alias for <code>macroexpand-all</code>, so in principle you could do</p>\n\n<pre><code>(require 'cl)\n</code></pre>\n\n<p>in your init file to fix the problem. However, the <code>cl</code> library itself is being deprecated, and using it is not recommended.</p>\n\n<p>I think you should contact the authors of <code>php-mode</code> and tell them to use <code>macroexpand-all</code>.</p>\n"},{"owner":{"reputation":631,"user_id":1979,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6d7d7689f9562293f6106353a6b1a905?s=128&d=identicon&r=PG","display_name":"Stefan","link":"http://emacs.stackexchange.com/users/1979/stefan"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414759512,"creation_date":1414759512,"answer_id":2906,"question_id":2864,"body_markdown":"It's bug#18845 in Emacs-24.4. To work around it, you need to add `(require 'cl)` somewhere before you load php-mode.","link":"http://emacs.stackexchange.com/questions/2864/symbols-function-definition-is-void-cl-macroexpand-all-when-trying-to-instal/2906#2906","title":""Symbol's function definition is void: cl-macroexpand-all" when trying to install php-mode","body":"<p>It's bug#18845 in Emacs-24.4. To work around it, you need to add <code>(require 'cl)</code> somewhere before you load php-mode.</p>\n"}],"tags":["package","cl-lib","php-mode"],"owner":{"reputation":13,"user_id":2342,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/8910de37dfedaf187c4b39005b809bdf?s=128&d=identicon&r=PG","display_name":"cg433n","link":"http://emacs.stackexchange.com/users/2342/cg433n"},"last_editor":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"comment_count":0,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":28,"favorite_count":0,"accepted_answer_id":2866,"answer_count":2,"score":2,"last_activity_date":1414759512,"creation_date":1414700357,"last_edit_date":1414701459,"question_id":2864,"body_markdown":"I'm trying to install [php-mode](https://github.com/ejmr/php-mode), but I keep encountering this error when I run `M-x php-mode`:\r\n\r\n Symbol's function definition is void: cl-macroexpand-all\r\n\r\nThe error persists whether I install php-mode via MELPA or manually.\r\n\r\nEnvironment: Emacs 24.3.94.1 (x86_64-apple-darwin13.4.0, NS apple-appkit-1265.21)\r\n of 2014-10-04 on builder10-9.porkrind.org\r\n\r\nWhy won't php-mode run? Note: I'm relatively new to Emacs, and inexperienced.","link":"http://emacs.stackexchange.com/questions/2864/symbols-function-definition-is-void-cl-macroexpand-all-when-trying-to-instal","title":""Symbol's function definition is void: cl-macroexpand-all" when trying to install php-mode","body":"<p>I'm trying to install <a href=\"https://github.com/ejmr/php-mode\" rel=\"nofollow\">php-mode</a>, but I keep encountering this error when I run <code>M-x php-mode</code>:</p>\n\n<pre><code>Symbol's function definition is void: cl-macroexpand-all\n</code></pre>\n\n<p>The error persists whether I install php-mode via MELPA or manually.</p>\n\n<p>Environment: Emacs 24.3.94.1 (x86_64-apple-darwin13.4.0, NS apple-appkit-1265.21)\n of 2014-10-04 on builder10-9.porkrind.org</p>\n\n<p>Why won't php-mode run? Note: I'm relatively new to Emacs, and inexperienced.</p>\n"},{"answers":[{"owner":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"comments":[{"owner":{"reputation":101,"user_id":362,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2ace292d4a9e6612e6cd761a1046f4f3?s=128&d=identicon&r=PG","display_name":"nic ferrier","link":"http://emacs.stackexchange.com/users/362/nic-ferrier"},"edited":false,"score":2,"post_type":"answer","creation_date":1411843196,"post_id":373,"comment_id":514,"body_markdown":"Using gdb would be the only way. We could add stuff to Emacs to wrap every C call in something that would self catch but that would be overhead all the time. Emacs is not supposed to crash, if it does we should specifically handle that bug so that it doesn't anymore. So yeah, if it's broken, file a bug. Use gdb by all means to find out absolutely where the bug is.","link":"http://emacs.stackexchange.com/questions/363/better-debugging-of-crashing-emacs/373#comment514_373","body":"Using gdb would be the only way. We could add stuff to Emacs to wrap every C call in something that would self catch but that would be overhead all the time. Emacs is not supposed to crash, if it does we should specifically handle that bug so that it doesn't anymore. So yeah, if it's broken, file a bug. Use gdb by all means to find out absolutely where the bug is."}],"last_editor":{"reputation":874,"user_id":11,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/e3d4212415bc280a21ad85d8022791fe?s=128&d=identicon&r=PG","display_name":"legoscia","link":"http://emacs.stackexchange.com/users/11/legoscia"},"comment_count":1,"is_accepted":true,"score":4,"last_activity_date":1411859526,"last_edit_date":1411859526,"creation_date":1411836111,"answer_id":373,"question_id":363,"body_markdown":"## To help you track it next time ##\r\n\r\nThis happened to me before. There was a situation where\r\n`string-to-int` crashed Emacs, and it took me hours to pinpoint as\r\nwell. \r\nSorry I can't provide a nicer answer, but Emacs crashes happen\r\ndeep down in the C code, and there aren't any built-in tools available\r\nto track down such problems.\r\n\r\nI suppose debugging it with `gdb` is possible, but its\r\neffectiveness will depend on your proficiency with `gdb`.\r\n\r\nWhat you really need to do is\r\n## File a bug report ##\r\n\r\nPure elisp code (non-byte-compiled) is never supposed to crash Emacs.\r\nIt could cause a hang (due to some infinite loop) and it could cause\r\nEmacs to run out of memory. But, beyond that, **any crash is a bug**.\r\n\r\n M-x report-emacs-bug\r\n\r\nSimply providing this minimally working example you came up with,\r\nalong with a description of your build and system, should be enough\r\nhelp for the kind developers.\r\n\r\n","link":"http://emacs.stackexchange.com/questions/363/better-debugging-of-crashing-emacs/373#373","title":"Better debugging of crashing Emacs?","body":"<h2>To help you track it next time</h2>\n\n<p>This happened to me before. There was a situation where\n<code>string-to-int</code> crashed Emacs, and it took me hours to pinpoint as\nwell.<br>\nSorry I can't provide a nicer answer, but Emacs crashes happen\ndeep down in the C code, and there aren't any built-in tools available\nto track down such problems.</p>\n\n<p>I suppose debugging it with <code>gdb</code> is possible, but its\neffectiveness will depend on your proficiency with <code>gdb</code>.</p>\n\n<p>What you really need to do is</p>\n\n<h2>File a bug report</h2>\n\n<p>Pure elisp code (non-byte-compiled) is never supposed to crash Emacs.\nIt could cause a hang (due to some infinite loop) and it could cause\nEmacs to run out of memory. But, beyond that, <strong>any crash is a bug</strong>.</p>\n\n<pre><code>M-x report-emacs-bug\n</code></pre>\n\n<p>Simply providing this minimally working example you came up with,\nalong with a description of your build and system, should be enough\nhelp for the kind developers.</p>\n"},{"owner":{"reputation":428,"user_id":129,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/2a1ad379159a4f4eaf5b54c5dbfe235a?s=128&d=identicon&r=PG","display_name":"stsquad","link":"http://emacs.stackexchange.com/users/129/stsquad"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414757838,"creation_date":1414757838,"answer_id":2905,"question_id":363,"body_markdown":"As a reference to debug with gdb you'll want to use src/temacs from the build tree. This is Emacs without the pre-dumped elisp which confuses the debugger.\r\n\r\n gdb --args src/temacs -nw","link":"http://emacs.stackexchange.com/questions/363/better-debugging-of-crashing-emacs/2905#2905","title":"Better debugging of crashing Emacs?","body":"<p>As a reference to debug with gdb you'll want to use src/temacs from the build tree. This is Emacs without the pre-dumped elisp which confuses the debugger.</p>\n\n<pre><code>gdb --args src/temacs -nw\n</code></pre>\n"}],"tags":["elisp","fonts","debugging","crash"],"owner":{"reputation":79,"user_id":249,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/f56e324b45b74edb72eb1d230554f83f?s=128&d=identicon&r=PG","display_name":"gsl","link":"http://emacs.stackexchange.com/users/249/gsl"},"comments":[{"owner":{"reputation":101,"user_id":362,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2ace292d4a9e6612e6cd761a1046f4f3?s=128&d=identicon&r=PG","display_name":"nic ferrier","link":"http://emacs.stackexchange.com/users/362/nic-ferrier"},"edited":false,"score":0,"post_type":"question","creation_date":1411821158,"post_id":363,"comment_id":496,"body_markdown":"is it really launching from the cli? or launching the terminal version that is causing the problem?\n\nTry putting some error catching around the set-face-attribute? (condition-case err (set-face-attribute...) (error (message "Whoops!")))","link":"http://emacs.stackexchange.com/questions/363/better-debugging-of-crashing-emacs#comment496_363","body":"is it really launching from the cli? or launching the terminal version that is causing the problem? Try putting some error catching around the set-face-attribute? (condition-case err (set-face-attribute...) (error (message "Whoops!")))"},{"owner":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":2,"post_type":"question","creation_date":1411825058,"post_id":363,"comment_id":497,"body_markdown":"File a bug report. Emacs should never crash due to lisp code. But this may be a problem with the specific build you're using, is it the official release?","link":"http://emacs.stackexchange.com/questions/363/better-debugging-of-crashing-emacs#comment497_363","body":"File a bug report. Emacs should never crash due to lisp code. But this may be a problem with the specific build you're using, is it the official release?"},{"owner":{"reputation":79,"user_id":249,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/f56e324b45b74edb72eb1d230554f83f?s=128&d=identicon&r=PG","display_name":"gsl","link":"http://emacs.stackexchange.com/users/249/gsl"},"reply_to_user":{"reputation":101,"user_id":362,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2ace292d4a9e6612e6cd761a1046f4f3?s=128&d=identicon&r=PG","display_name":"nic ferrier","link":"http://emacs.stackexchange.com/users/362/nic-ferrier"},"edited":false,"score":0,"post_type":"question","creation_date":1411827222,"post_id":363,"comment_id":498,"body_markdown":"@nic-ferrier: I have now just one line in init.el, `(condition-case err (set-face-attribute 'default nil :font "Menlo-16") (error (message "Whoops!")))` still I have the same crash with same error message. No additional elisp-originating messages.","link":"http://emacs.stackexchange.com/questions/363/better-debugging-of-crashing-emacs#comment498_363","body":"@nic-ferrier: I have now just one line in init.el, <code>(condition-case err (set-face-attribute 'default nil :font "Menlo-16") (error (message "Whoops!")))</code> still I have the same crash with same error message. No additional elisp-originating messages."},{"owner":{"reputation":79,"user_id":249,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/f56e324b45b74edb72eb1d230554f83f?s=128&d=identicon&r=PG","display_name":"gsl","link":"http://emacs.stackexchange.com/users/249/gsl"},"edited":false,"score":0,"post_type":"question","creation_date":1411827657,"post_id":363,"comment_id":499,"body_markdown":"@ malabarba: I have tried with `GNU Emacs 24.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36) of 2013-03-13 on bob.porkrind.org` from http://emacsformacosx.com, and Emacs does not crash. So, it must be a bug in later versions.\n\nI shall file a bug report.","link":"http://emacs.stackexchange.com/questions/363/better-debugging-of-crashing-emacs#comment499_363","body":"@ malabarba: I have tried with <code>GNU Emacs 24.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36) of 2013-03-13 on bob.porkrind.org</code> from <a href=\"http://emacsformacosx.com\" rel=\"nofollow\">emacsformacosx.com</a>, and Emacs does not crash. So, it must be a bug in later versions. I shall file a bug report."},{"owner":{"reputation":79,"user_id":249,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/f56e324b45b74edb72eb1d230554f83f?s=128&d=identicon&r=PG","display_name":"gsl","link":"http://emacs.stackexchange.com/users/249/gsl"},"reply_to_user":{"reputation":101,"user_id":362,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2ace292d4a9e6612e6cd761a1046f4f3?s=128&d=identicon&r=PG","display_name":"nic ferrier","link":"http://emacs.stackexchange.com/users/362/nic-ferrier"},"edited":false,"score":0,"post_type":"question","creation_date":1411827812,"post_id":363,"comment_id":500,"body_markdown":"@nic-ferrier @malabarba Would you mind adding an answer to point 1, so that this could be useful to others for future similar issues? Tracking the source of the bug was really time consuming. Is there any way to use an external debugger? Using @nic-ferrier's suggestion of `condition-case err` did not work in this case.","link":"http://emacs.stackexchange.com/questions/363/better-debugging-of-crashing-emacs#comment500_363","body":"@nic-ferrier @malabarba Would you mind adding an answer to point 1, so that this could be useful to others for future similar issues? Tracking the source of the bug was really time consuming. Is there any way to use an external debugger? Using @nic-ferrier's suggestion of <code>condition-case err</code> did not work in this case."},{"owner":{"reputation":1487,"user_id":160,"user_type":"registered","profile_image":"http://i.stack.imgur.com/y27jq.png?s=128&g=1","display_name":"Jordon Biondo","link":"http://emacs.stackexchange.com/users/160/jordon-biondo"},"edited":false,"score":0,"post_type":"question","creation_date":1411829310,"post_id":363,"comment_id":502,"body_markdown":"@gsl, are you saying the condition case didn't catch it? I can reproduce the seg fault over here, but wrapping it in a condition case does stop the crash, the error I get when wrapped is that :font is not a face attribute which makes sense in a -nw environment, but the crash should not happen, only the error.\n\nspecifically, the error I get is: `(error "Invalid face attribute name" :face)` when condition-cased\n\nThat being said, you should use `set-default-font` to set the font, not set-face-attribute.","link":"http://emacs.stackexchange.com/questions/363/better-debugging-of-crashing-emacs#comment502_363","body":"@gsl, are you saying the condition case didn't catch it? I can reproduce the seg fault over here, but wrapping it in a condition case does stop the crash, the error I get when wrapped is that :font is not a face attribute which makes sense in a -nw environment, but the crash should not happen, only the error. specifically, the error I get is: <code>(error "Invalid face attribute name" :face)</code> when condition-cased That being said, you should use <code>set-default-font</code> to set the font, not set-face-attribute."},{"owner":{"reputation":79,"user_id":249,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/f56e324b45b74edb72eb1d230554f83f?s=128&d=identicon&r=PG","display_name":"gsl","link":"http://emacs.stackexchange.com/users/249/gsl"},"reply_to_user":{"reputation":1487,"user_id":160,"user_type":"registered","profile_image":"http://i.stack.imgur.com/y27jq.png?s=128&g=1","display_name":"Jordon Biondo","link":"http://emacs.stackexchange.com/users/160/jordon-biondo"},"edited":false,"score":0,"post_type":"question","creation_date":1411830743,"post_id":363,"comment_id":505,"body_markdown":"@jordon-biondo Yes, if I have just this line `(condition-case err (set-face-attribute 'default nil :font "Menlo-16") (error (message "Whoops!")))`, the condition case didn't catch it. I just get `Fatal error 11: Segmentation fault`. Thank you for pointing out to use `set-default-font` instead.","link":"http://emacs.stackexchange.com/questions/363/better-debugging-of-crashing-emacs#comment505_363","body":"@jordon-biondo Yes, if I have just this line <code>(condition-case err (set-face-attribute 'default nil :font "Menlo-16") (error (message "Whoops!")))</code>, the condition case didn't catch it. I just get <code>Fatal error 11: Segmentation fault</code>. Thank you for pointing out to use <code>set-default-font</code> instead."},{"owner":{"reputation":1487,"user_id":160,"user_type":"registered","profile_image":"http://i.stack.imgur.com/y27jq.png?s=128&g=1","display_name":"Jordon Biondo","link":"http://emacs.stackexchange.com/users/160/jordon-biondo"},"edited":false,"score":0,"post_type":"question","creation_date":1411831338,"post_id":363,"comment_id":506,"body_markdown":"Looks like I typed the wrong face attribute it, ignore my comment.","link":"http://emacs.stackexchange.com/questions/363/better-debugging-of-crashing-emacs#comment506_363","body":"Looks like I typed the wrong face attribute it, ignore my comment."},{"owner":{"reputation":3478,"user_id":105,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/32a8e553d85d193ee5ae1533ce6ec158?s=128&d=identicon&r=PG&f=1","display_name":"Drew","link":"http://emacs.stackexchange.com/users/105/drew"},"reply_to_user":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":1,"post_type":"question","creation_date":1411833053,"post_id":363,"comment_id":508,"body_markdown":"As @Malabarba indicated: **File a bug report** (immediately): `M-x report-emacs-bug`. Emacs developers will then lead you through what you can do to help debug the problem.","link":"http://emacs.stackexchange.com/questions/363/better-debugging-of-crashing-emacs#comment508_363","body":"As @Malabarba indicated: <b>File a bug report</b> (immediately): <code>M-x report-emacs-bug</code>. Emacs developers will then lead you through what you can do to help debug the problem."},{"owner":{"reputation":79,"user_id":249,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/f56e324b45b74edb72eb1d230554f83f?s=128&d=identicon&r=PG","display_name":"gsl","link":"http://emacs.stackexchange.com/users/249/gsl"},"reply_to_user":{"reputation":3478,"user_id":105,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/32a8e553d85d193ee5ae1533ce6ec158?s=128&d=identicon&r=PG&f=1","display_name":"Drew","link":"http://emacs.stackexchange.com/users/105/drew"},"edited":false,"score":0,"post_type":"question","creation_date":1411834454,"post_id":363,"comment_id":509,"body_markdown":"@drew Thank you, I just did.","link":"http://emacs.stackexchange.com/questions/363/better-debugging-of-crashing-emacs#comment509_363","body":"@drew Thank you, I just did."},{"owner":{"reputation":3478,"user_id":105,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/32a8e553d85d193ee5ae1533ce6ec158?s=128&d=identicon&r=PG&f=1","display_name":"Drew","link":"http://emacs.stackexchange.com/users/105/drew"},"edited":false,"score":0,"post_type":"question","creation_date":1411834533,"post_id":363,"comment_id":510,"body_markdown":"Great. Here's wishing a fruitful followup and a fix. Thx.","link":"http://emacs.stackexchange.com/questions/363/better-debugging-of-crashing-emacs#comment510_363","body":"Great. Here's wishing a fruitful followup and a fix. Thx."}],"last_editor":{"reputation":79,"user_id":249,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/f56e324b45b74edb72eb1d230554f83f?s=128&d=identicon&r=PG","display_name":"gsl","link":"http://emacs.stackexchange.com/users/249/gsl"},"comment_count":11,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":63,"favorite_count":1,"accepted_answer_id":373,"answer_count":2,"score":4,"last_activity_date":1414757838,"creation_date":1411809580,"last_edit_date":1411830937,"question_id":363,"body_markdown":"Although Emacs (24.3.93.1) runs fine if launched from the Finder, if the terminal version is launched:\r\n\r\n`/Applications/Emacs.app/Contents/MacOS/Emacs -nw`\r\n\r\nEmacs crashes with:\r\n\r\n`Fatal error 11: Segmentation fault[1] 51512 abort /Applications/Emacs.app/Contents/MacOS/Emacs -nw`.\r\n\r\nIt seems the issue is caused by a single line in init.el,\r\n\r\n`(set-face-attribute 'default nil :font "Menlo-16")`\r\n\r\nIf that line is commented out, the terminal version of Emacs will start fine too.\r\n\r\nTo pinpoint the cause of the crash took me several hours (diminishing my init.el half by half).\r\n\r\nI am aware that in any case Emacs will inherit whatever font and font size is specified in the terminal app (basically, that line is not meaningful in the cli.)\r\n\r\n 1. Generally speaking, is there a better way to debug a crashing Emacs? Perhaps using some kind of cli debugger that would print a more descriptive message?\r\n 2. Why is that line crashing Emacs via cli, but not if launched from the Finder?\r\n","link":"http://emacs.stackexchange.com/questions/363/better-debugging-of-crashing-emacs","title":"Better debugging of crashing Emacs?","body":"<p>Although Emacs (24.3.93.1) runs fine if launched from the Finder, if the terminal version is launched:</p>\n\n<p><code>/Applications/Emacs.app/Contents/MacOS/Emacs -nw</code></p>\n\n<p>Emacs crashes with:</p>\n\n<p><code>Fatal error 11: Segmentation fault[1] 51512 abort /Applications/Emacs.app/Contents/MacOS/Emacs -nw</code>.</p>\n\n<p>It seems the issue is caused by a single line in init.el,</p>\n\n<p><code>(set-face-attribute 'default nil :font \"Menlo-16\")</code></p>\n\n<p>If that line is commented out, the terminal version of Emacs will start fine too.</p>\n\n<p>To pinpoint the cause of the crash took me several hours (diminishing my init.el half by half).</p>\n\n<p>I am aware that in any case Emacs will inherit whatever font and font size is specified in the terminal app (basically, that line is not meaningful in the cli.)</p>\n\n<ol>\n<li>Generally speaking, is there a better way to debug a crashing Emacs? Perhaps using some kind of cli debugger that would print a more descriptive message?</li>\n<li>Why is that line crashing Emacs via cli, but not if launched from the Finder?</li>\n</ol>\n"},{"tags":["org-mode","reftex-mode","bibtex"],"owner":{"reputation":41,"user_id":201,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/18452c228ede1b8db735a6c310068947?s=128&d=identicon&r=PG","display_name":"petrux","link":"http://emacs.stackexchange.com/users/201/petrux"},"last_editor":{"reputation":860,"user_id":10,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1504319df63de7148c39290d4149f150?s=128&d=identicon&r=PG","display_name":"wasamasa","link":"http://emacs.stackexchange.com/users/10/wasamasa"},"comment_count":0,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":false,"view_count":10,"favorite_count":0,"answer_count":0,"score":0,"last_activity_date":1414754843,"creation_date":1414754222,"last_edit_date":1414754843,"question_id":2901,"body_markdown":"I'm trying to set upt `org-mode` and `reftex-mode` but I'm getting some troubles. Here is my `init.el` file: \r\n \r\n\r\n ;; ORG-MODE\r\n (add-to-list 'auto-mode-alist '("\\\\.org\\\\'" . org-mode))\r\n (setq org-agenda-files '("~/.../"))\r\n (global-set-key "\\C-ca" 'org-agenda)\r\n (add-hook 'org-mode-hook\r\n \t (lambda ()\r\n \t (reftex-mode)\r\n \t (visual-line-mode)\r\n \t (company-mode)))\r\n \r\n\r\nI'm trying to load a `.bib` file with `(setq reftex-default-bibliography '("path/to/bibfile.bib"))` and it seems to work fine, but as I type `C-c [` in order to add a new reference I got this error: \r\n \r\n`reftex-using-biblatex-p: Stack overflow in regexp matcher` \r\n \r\nAny hint? Thanks in advance. \r\n \r\n*P.S. couldn't tag with* `reftex-mode` *nor* `bibtex` *as I have no enough reputation score. If anyone could, I think thah would be good!*","link":"http://emacs.stackexchange.com/questions/2901/org-mode-and-reftex-giving-this-error-reftex-using-biblatex-p-stack-overflow-i","title":"org-mode and reftex giving this error: reftex-using-biblatex-p: Stack overflow in regexp matcher","body":"<p>I'm trying to set upt <code>org-mode</code> and <code>reftex-mode</code> but I'm getting some troubles. Here is my <code>init.el</code> file: </p>\n\n<pre><code>;; ORG-MODE\n(add-to-list 'auto-mode-alist '(\"\\\\.org\\\\'\" . org-mode))\n(setq org-agenda-files '(\"~/.../\"))\n(global-set-key \"\\C-ca\" 'org-agenda)\n(add-hook 'org-mode-hook\n (lambda ()\n (reftex-mode)\n (visual-line-mode)\n (company-mode)))\n</code></pre>\n\n<p>I'm trying to load a <code>.bib</code> file with <code>(setq reftex-default-bibliography '(\"path/to/bibfile.bib\"))</code> and it seems to work fine, but as I type <code>C-c [</code> in order to add a new reference I got this error: </p>\n\n<p><code>reftex-using-biblatex-p: Stack overflow in regexp matcher</code> </p>\n\n<p>Any hint? Thanks in advance. </p>\n\n<p><em>P.S. couldn't tag with</em> <code>reftex-mode</code> <em>nor</em> <code>bibtex</code> <em>as I have no enough reputation score. If anyone could, I think thah would be good!</em></p>\n"},{"answers":[{"owner":{"reputation":131,"user_id":110,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a31fbafa397845ab6ec33df5139ae589?s=128&d=identicon&r=PG","display_name":"tenpn","link":"http://emacs.stackexchange.com/users/110/tenpn"},"comment_count":0,"is_accepted":false,"score":3,"last_activity_date":1414751847,"creation_date":1414751847,"answer_id":2900,"question_id":2899,"body_markdown":"My problem was that the byte-compiled version of csharp-mode wasn't compatible with the upgrade. It seems it's a good idea to recompile all files on upgrading emacs, see this question: http://stackoverflow.com/questions/24725778/how-to-rebuild-elpa-packages-after-upgrade-of-emacs\r\n\r\ntl;dr: `M-: (byte-recompile-directory package-user-dir nil 'force)` fixes all problems.","link":"http://emacs.stackexchange.com/questions/2899/recursive-load-error-in-csharp-mode-on-upgrading-to-24-4/2900#2900","title":"Recursive load error in csharp mode on upgrading to 24.4","body":"<p>My problem was that the byte-compiled version of csharp-mode wasn't compatible with the upgrade. It seems it's a good idea to recompile all files on upgrading emacs, see this question: <a href=\"http://stackoverflow.com/questions/24725778/how-to-rebuild-elpa-packages-after-upgrade-of-emacs\">http://stackoverflow.com/questions/24725778/how-to-rebuild-elpa-packages-after-upgrade-of-emacs</a></p>\n\n<p>tl;dr: <code>M-: (byte-recompile-directory package-user-dir nil 'force)</code> fixes all problems.</p>\n"}],"tags":["emacs24.4"],"owner":{"reputation":131,"user_id":110,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a31fbafa397845ab6ec33df5139ae589?s=128&d=identicon&r=PG","display_name":"tenpn","link":"http://emacs.stackexchange.com/users/110/tenpn"},"comments":[{"owner":{"reputation":145,"user_id":295,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/57577324241ffa414154a4eb7589c3b6?s=128&d=identicon&r=PG","display_name":"Tom Regner","link":"http://emacs.stackexchange.com/users/295/tom-regner"},"edited":false,"score":1,"post_type":"question","creation_date":1414750951,"post_id":2899,"comment_id":3952,"body_markdown":"Did you recompile csharp-mode.el after the update?","link":"http://emacs.stackexchange.com/questions/2899/recursive-load-error-in-csharp-mode-on-upgrading-to-24-4#comment3952_2899","body":"Did you recompile csharp-mode.el after the update?"},{"owner":{"reputation":131,"user_id":110,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a31fbafa397845ab6ec33df5139ae589?s=128&d=identicon&r=PG","display_name":"tenpn","link":"http://emacs.stackexchange.com/users/110/tenpn"},"reply_to_user":{"reputation":145,"user_id":295,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/57577324241ffa414154a4eb7589c3b6?s=128&d=identicon&r=PG","display_name":"Tom Regner","link":"http://emacs.stackexchange.com/users/295/tom-regner"},"edited":false,"score":0,"post_type":"question","creation_date":1414751549,"post_id":2899,"comment_id":3953,"body_markdown":"I just upgraded then re-opened emacs. Deleting the .elc files for csharp in the elpa dir did fix the problem, but that's probably not the proper thing to do. What's the best way to recompile all packages?","link":"http://emacs.stackexchange.com/questions/2899/recursive-load-error-in-csharp-mode-on-upgrading-to-24-4#comment3953_2899","body":"I just upgraded then re-opened emacs. Deleting the .elc files for csharp in the elpa dir did fix the problem, but that's probably not the proper thing to do. What's the best way to recompile all packages?"},{"owner":{"reputation":131,"user_id":110,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a31fbafa397845ab6ec33df5139ae589?s=128&d=identicon&r=PG","display_name":"tenpn","link":"http://emacs.stackexchange.com/users/110/tenpn"},"reply_to_user":{"reputation":145,"user_id":295,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/57577324241ffa414154a4eb7589c3b6?s=128&d=identicon&r=PG","display_name":"Tom Regner","link":"http://emacs.stackexchange.com/users/295/tom-regner"},"edited":false,"score":0,"post_type":"question","creation_date":1414751582,"post_id":2899,"comment_id":3954,"body_markdown":"ah: http://stackoverflow.com/questions/24725778/how-to-rebuild-elpa-packages-after-upgrade-of-emacs","link":"http://emacs.stackexchange.com/questions/2899/recursive-load-error-in-csharp-mode-on-upgrading-to-24-4#comment3954_2899","body":"ah: <a href=\"http://stackoverflow.com/questions/24725778/how-to-rebuild-elpa-packages-after-upgrade-of-emacs\" title=\"how to rebuild elpa packages after upgrade of emacs\">stackoverflow.com/questions/24725778/…</a>"},{"owner":{"reputation":131,"user_id":110,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a31fbafa397845ab6ec33df5139ae589?s=128&d=identicon&r=PG","display_name":"tenpn","link":"http://emacs.stackexchange.com/users/110/tenpn"},"reply_to_user":{"reputation":145,"user_id":295,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/57577324241ffa414154a4eb7589c3b6?s=128&d=identicon&r=PG","display_name":"Tom Regner","link":"http://emacs.stackexchange.com/users/295/tom-regner"},"edited":false,"score":0,"post_type":"question","creation_date":1414751622,"post_id":2899,"comment_id":3955,"body_markdown":"`M-: (byte-recompile-directory package-user-dir nil 'force)`","link":"http://emacs.stackexchange.com/questions/2899/recursive-load-error-in-csharp-mode-on-upgrading-to-24-4#comment3955_2899","body":"<code>M-: (byte-recompile-directory package-user-dir nil 'force)</code>"},{"owner":{"reputation":145,"user_id":295,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/57577324241ffa414154a4eb7589c3b6?s=128&d=identicon&r=PG","display_name":"Tom Regner","link":"http://emacs.stackexchange.com/users/295/tom-regner"},"edited":false,"score":0,"post_type":"question","creation_date":1414751821,"post_id":2899,"comment_id":3956,"body_markdown":"Cool! Most problems I encounter after an update are due to old byte-code, I'm glad that was your problem too.","link":"http://emacs.stackexchange.com/questions/2899/recursive-load-error-in-csharp-mode-on-upgrading-to-24-4#comment3956_2899","body":"Cool! Most problems I encounter after an update are due to old byte-code, I'm glad that was your problem too."}],"comment_count":5,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":15,"favorite_count":0,"answer_count":1,"score":0,"last_activity_date":1414751847,"creation_date":1414750343,"question_id":2899,"body_markdown":"I'm on OSX 10.9.4 and I was previously running emacs 24.3 installed via brew.\r\n\r\nThis morning I got around to asking brew to upgrade me to 24.4. Everything seemed to go smoothly, except csharp-mode no longer functions correctly. On opening a .cs file I get this error:\r\n\r\n File mode specification error: (error "Recursive load" \r\n "/Users/Andrew/.emacs.d/elpa/csharp-mode-20120204.1826/csharp-mode.elc" \r\n "/Users/Andrew/.emacs.d/elpa/csharp-mode-20120204.1826/csharp-mode.elc" \r\n "/Users/Andrew/.emacs.d/elpa/csharp-mode-20120204.1826/csharp-mode.elc" \r\n "/Users/Andrew/.emacs.d/elpa/csharp-mode-20120204.1826/csharp-mode.elc" \r\n "/Users/Andrew/.emacs.d/elpa/csharp-mode-20120204.1826/csharp-mode.elc")\r\n\r\nI still have 24.3 on my machine and I can open .cs files correctly in that. \r\n\r\nUnfortunately csharp mode [seems to be dead][1] - it's not been touched in a few years. Any help or pointers as to how I can hack this to work would be appreciated.\r\n\r\n\r\n [1]: http://www.emacswiki.org/CSharpMode","link":"http://emacs.stackexchange.com/questions/2899/recursive-load-error-in-csharp-mode-on-upgrading-to-24-4","title":"Recursive load error in csharp mode on upgrading to 24.4","body":"<p>I'm on OSX 10.9.4 and I was previously running emacs 24.3 installed via brew.</p>\n\n<p>This morning I got around to asking brew to upgrade me to 24.4. Everything seemed to go smoothly, except csharp-mode no longer functions correctly. On opening a .cs file I get this error:</p>\n\n<pre><code>File mode specification error: (error \"Recursive load\" \n \"/Users/Andrew/.emacs.d/elpa/csharp-mode-20120204.1826/csharp-mode.elc\" \n \"/Users/Andrew/.emacs.d/elpa/csharp-mode-20120204.1826/csharp-mode.elc\" \n \"/Users/Andrew/.emacs.d/elpa/csharp-mode-20120204.1826/csharp-mode.elc\" \n \"/Users/Andrew/.emacs.d/elpa/csharp-mode-20120204.1826/csharp-mode.elc\" \n \"/Users/Andrew/.emacs.d/elpa/csharp-mode-20120204.1826/csharp-mode.elc\")\n</code></pre>\n\n<p>I still have 24.3 on my machine and I can open .cs files correctly in that. </p>\n\n<p>Unfortunately csharp mode <a href=\"http://www.emacswiki.org/CSharpMode\" rel=\"nofollow\">seems to be dead</a> - it's not been touched in a few years. Any help or pointers as to how I can hack this to work would be appreciated.</p>\n"},{"answers":[{"owner":{"reputation":119,"user_id":320,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ab1c0a3172eecaa6ad0a44b6c84bc723?s=128&d=identicon&r=PG","display_name":"Mathias Dahl","link":"http://emacs.stackexchange.com/users/320/mathias-dahl"},"comments":[{"owner":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":2,"post_type":"answer","creation_date":1414710921,"post_id":2878,"comment_id":3929,"body_markdown":"If something is being done non-interactively I can't see any scenario in which you'd want *" the buffer contents to be close to what find-file would produce"*. find-file is slow because it does a ton of unnecessary stuff, including all sorts of hooks. The only "feature" of find-file which you might want is the major-mode, but then you should just activate it yourself (you can't even guarantee find-file would turn on the mode that you want anyway).","link":"http://emacs.stackexchange.com/questions/2868/whats-wrong-with-find-file-noselect/2878#comment3929_2878","body":"If something is being done non-interactively I can't see any scenario in which you'd want <i>" the buffer contents to be close to what find-file would produce"</i>. find-file is slow because it does a ton of unnecessary stuff, including all sorts of hooks. The only "feature" of find-file which you might want is the major-mode, but then you should just activate it yourself (you can't even guarantee find-file would turn on the mode that you want anyway)."}],"comment_count":1,"is_accepted":false,"score":3,"last_activity_date":1414710116,"creation_date":1414710116,"answer_id":2878,"question_id":2868,"body_markdown":"From section 24.3 in the Elisp manual:\r\n\r\n> To copy the contents of a file into a buffer, use the function\r\n> `insert-file-contents`. (Don't use the command `insert-file` in a\r\n> Lisp program, as that sets the mark.)\r\n\r\nSearching the Elisp documentation for `find-file-noselect` it is obvious that it does much more than just reading a file into a buffer. Perhaps people who think using this function is a bad idea are thinking about the, possibly unwanted, side-effects? I guess it depends on what you want to achieve. If you want to have as clean/untouched buffer content as possible, it might be a good idea to use the old and trusty `with-temp-buffer` + `insert-file-contents `combination. If you want the buffer contents to be as close to what `find-file` produce, perhaps you *do* want to use `find-file-noselect`? Or perhaps he was thinking about `find-file` ;)\r\n","link":"http://emacs.stackexchange.com/questions/2868/whats-wrong-with-find-file-noselect/2878#2878","title":"What's wrong with `find-file-noselect`?","body":"<p>From section 24.3 in the Elisp manual:</p>\n\n<blockquote>\n <p>To copy the contents of a file into a buffer, use the function\n <code>insert-file-contents</code>. (Don't use the command <code>insert-file</code> in a\n Lisp program, as that sets the mark.)</p>\n</blockquote>\n\n<p>Searching the Elisp documentation for <code>find-file-noselect</code> it is obvious that it does much more than just reading a file into a buffer. Perhaps people who think using this function is a bad idea are thinking about the, possibly unwanted, side-effects? I guess it depends on what you want to achieve. If you want to have as clean/untouched buffer content as possible, it might be a good idea to use the old and trusty <code>with-temp-buffer</code> + <code>insert-file-contents</code>combination. If you want the buffer contents to be as close to what <code>find-file</code> produce, perhaps you <em>do</em> want to use <code>find-file-noselect</code>? Or perhaps he was thinking about <code>find-file</code> ;)</p>\n"},{"owner":{"reputation":1643,"user_id":227,"user_type":"registered","profile_image":"http://i.stack.imgur.com/Ltiwu.png?s=128&g=1","display_name":"lunaryorn","link":"http://emacs.stackexchange.com/users/227/lunaryorn"},"comment_count":0,"is_accepted":false,"score":5,"last_activity_date":1414749759,"creation_date":1414749759,"answer_id":2898,"question_id":2868,"body_markdown":"**TL;DR**: With `find-file-noselect` you have **no control** about what actually happens, and you may end up with arbitrary minor modes enabling in the buffer, depending on what the user enabled in their `init.el`. Also, cleanup is hard. \r\n\r\nUse `with-temp-buffer` and `insert-file-contents` instead. If you need specific major or minor modes in the buffer, enable them **explicitly**. To write files, use `with-temp-file` instead, which—despite its name—lets you write to arbitrary files.\r\n\r\n# Side effects\r\n\r\n`find-file-noselect` has **a lot** of side-effects, including\r\n\r\n- interactively asking questions (that alone is a no-go in non-interactive use),\r\n- automatically enabling view mode for readonly files,\r\n- entering normal mode otherwise,\r\n- and running `find-file-hook`.\r\n\r\nNormal Mode itself \r\n\r\n- automatically selects a proper major mode for the current buffer,\r\n- runs all corresponding major and minor mode hooks,\r\n- and reads all local variables for the current buffer, i.e. file variables and directory variables, which again may ask interactive questions about unsafe local variables.\r\n\r\nSince all hooks are run, you get **all minor modes and hook functions** the user enabled in their `init.el`, which can cause everything, from minor inconveniences (if undesirable minor modes are enabled) to major havoc (if the user added a hook function that expects to be called from an interactive context). \r\n\r\nSee https://github.com/flycheck/flycheck/issues/366 for an example. The use of `find-file-noselect` caused a data file to be syntax-checked by Flycheck, and since it was happening at Emacs shut-down, there was no time to properly clean up again, leaving a temporary file behind.\r\n\r\n# Cleanup\r\n\r\nWith `find-file-noselect` you need to be extra careful to kill the buffer again. `find-file-noselect` does not do that for you.\r\n\r\nYou need to remember the buffer at some place, and carefully use `unwind-protect` to make sure that the buffer gets killed even in case of non-local exits.\r\n\r\n# Alternatives\r\n\r\nTo read files, use `with-temp-buffer` and `insert-file-contents`, which only does the most basic things, e.g. coding system conversion, but does not ask questions, enable hooks, or setup local variables:\r\n\r\n (with-temp-buffer\r\n (insert-file-contents (locate-user-emacs-file "foo.el"))\r\n ;; Enter the major mode explicitly\r\n (emacs-lisp-mode)\r\n ;; …\r\n )\r\n\r\n`with-temp-buffer` takes care to properly kill the temporary buffer at the end of its body.\r\n\r\nTo write files, use `with-temp-file`, which creates a temporary buffer and writes the contents to the given file name at the end of its body:\r\n\r\n (with-temp-file (locate-user-emacs-file "foo.el")\r\n (prin1 (list 'my 'data) (current-buffer)))","link":"http://emacs.stackexchange.com/questions/2868/whats-wrong-with-find-file-noselect/2898#2898","title":"What's wrong with `find-file-noselect`?","body":"<p><strong>TL;DR</strong>: With <code>find-file-noselect</code> you have <strong>no control</strong> about what actually happens, and you may end up with arbitrary minor modes enabling in the buffer, depending on what the user enabled in their <code>init.el</code>. Also, cleanup is hard. </p>\n\n<p>Use <code>with-temp-buffer</code> and <code>insert-file-contents</code> instead. If you need specific major or minor modes in the buffer, enable them <strong>explicitly</strong>. To write files, use <code>with-temp-file</code> instead, which—despite its name—lets you write to arbitrary files.</p>\n\n<h1>Side effects</h1>\n\n<p><code>find-file-noselect</code> has <strong>a lot</strong> of side-effects, including</p>\n\n<ul>\n<li>interactively asking questions (that alone is a no-go in non-interactive use),</li>\n<li>automatically enabling view mode for readonly files,</li>\n<li>entering normal mode otherwise,</li>\n<li>and running <code>find-file-hook</code>.</li>\n</ul>\n\n<p>Normal Mode itself </p>\n\n<ul>\n<li>automatically selects a proper major mode for the current buffer,</li>\n<li>runs all corresponding major and minor mode hooks,</li>\n<li>and reads all local variables for the current buffer, i.e. file variables and directory variables, which again may ask interactive questions about unsafe local variables.</li>\n</ul>\n\n<p>Since all hooks are run, you get <strong>all minor modes and hook functions</strong> the user enabled in their <code>init.el</code>, which can cause everything, from minor inconveniences (if undesirable minor modes are enabled) to major havoc (if the user added a hook function that expects to be called from an interactive context). </p>\n\n<p>See <a href=\"https://github.com/flycheck/flycheck/issues/366\">https://github.com/flycheck/flycheck/issues/366</a> for an example. The use of <code>find-file-noselect</code> caused a data file to be syntax-checked by Flycheck, and since it was happening at Emacs shut-down, there was no time to properly clean up again, leaving a temporary file behind.</p>\n\n<h1>Cleanup</h1>\n\n<p>With <code>find-file-noselect</code> you need to be extra careful to kill the buffer again. <code>find-file-noselect</code> does not do that for you.</p>\n\n<p>You need to remember the buffer at some place, and carefully use <code>unwind-protect</code> to make sure that the buffer gets killed even in case of non-local exits.</p>\n\n<h1>Alternatives</h1>\n\n<p>To read files, use <code>with-temp-buffer</code> and <code>insert-file-contents</code>, which only does the most basic things, e.g. coding system conversion, but does not ask questions, enable hooks, or setup local variables:</p>\n\n<pre><code>(with-temp-buffer\n (insert-file-contents (locate-user-emacs-file \"foo.el\"))\n ;; Enter the major mode explicitly\n (emacs-lisp-mode)\n ;; …\n )\n</code></pre>\n\n<p><code>with-temp-buffer</code> takes care to properly kill the temporary buffer at the end of its body.</p>\n\n<p>To write files, use <code>with-temp-file</code>, which creates a temporary buffer and writes the contents to the given file name at the end of its body:</p>\n\n<pre><code>(with-temp-file (locate-user-emacs-file \"foo.el\")\n (prin1 (list 'my 'data) (current-buffer)))\n</code></pre>\n"}],"tags":["files","good-practices"],"owner":{"reputation":240,"user_id":642,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/d246baeefae20788d6ea519b777a99c7?s=128&d=identicon&r=PG","display_name":"mbork","link":"http://emacs.stackexchange.com/users/642/mbork"},"comments":[{"owner":{"reputation":240,"user_id":642,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/d246baeefae20788d6ea519b777a99c7?s=128&d=identicon&r=PG","display_name":"mbork","link":"http://emacs.stackexchange.com/users/642/mbork"},"edited":false,"score":0,"post_type":"question","creation_date":1414702978,"post_id":2868,"comment_id":3920,"body_markdown":"Seemingly, there was no `good-practices` tag before; is it a good idea to use it?","link":"http://emacs.stackexchange.com/questions/2868/whats-wrong-with-find-file-noselect#comment3920_2868","body":"Seemingly, there was no <code>good-practices</code> tag before; is it a good idea to use it?"},{"owner":{"reputation":1709,"user_id":93,"user_type":"registered","accept_rate":55,"profile_image":"https://www.gravatar.com/avatar/52ada69db49a5d75240cc0c989c934f4?s=128&d=identicon&r=PG","display_name":"nispio","link":"http://emacs.stackexchange.com/users/93/nispio"},"edited":false,"score":0,"post_type":"question","creation_date":1414706928,"post_id":2868,"comment_id":3927,"body_markdown":"I think that `good-practices` would fall under the category of "meta tag," which is [frowned upon](http://blog.stackoverflow.com/2010/08/the-death-of-meta-tags/) by SE.","link":"http://emacs.stackexchange.com/questions/2868/whats-wrong-with-find-file-noselect#comment3927_2868","body":"I think that <code>good-practices</code> would fall under the category of "meta tag," which is <a href=\"http://blog.stackoverflow.com/2010/08/the-death-of-meta-tags/\">frowned upon</a> by SE."},{"owner":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"reply_to_user":{"reputation":1709,"user_id":93,"user_type":"registered","accept_rate":55,"profile_image":"https://www.gravatar.com/avatar/52ada69db49a5d75240cc0c989c934f4?s=128&d=identicon&r=PG","display_name":"nispio","link":"http://emacs.stackexchange.com/users/93/nispio"},"edited":false,"score":0,"post_type":"question","creation_date":1414711034,"post_id":2868,"comment_id":3930,"body_markdown":"@nispio I think it's a valid tag, but we can take this to the meta of course.","link":"http://emacs.stackexchange.com/questions/2868/whats-wrong-with-find-file-noselect#comment3930_2868","body":"@nispio I think it's a valid tag, but we can take this to the meta of course."},{"owner":{"reputation":240,"user_id":642,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/d246baeefae20788d6ea519b777a99c7?s=128&d=identicon&r=PG","display_name":"mbork","link":"http://emacs.stackexchange.com/users/642/mbork"},"edited":false,"score":0,"post_type":"question","creation_date":1414765383,"post_id":2868,"comment_id":3981,"body_markdown":"@nsipio: I've skimmed through that article, and I don't agree. But it's not me who decides. ;-)","link":"http://emacs.stackexchange.com/questions/2868/whats-wrong-with-find-file-noselect#comment3981_2868","body":"@nsipio: I've skimmed through that article, and I don't agree. But it's not me who decides. ;-)"}],"last_editor":{"reputation":1217,"user_id":45,"user_type":"registered","accept_rate":93,"profile_image":"https://www.gravatar.com/avatar/073274c272b84eed27790fc3e5231d46?s=128&d=identicon&r=PG&f=1","display_name":"King Shimkus","link":"http://emacs.stackexchange.com/users/45/king-shimkus"},"comment_count":4,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":56,"favorite_count":1,"answer_count":2,"score":6,"last_activity_date":1414749759,"creation_date":1414702933,"last_edit_date":1414705404,"question_id":2868,"body_markdown":"In a recent [answer][1] by [lunaryorn][2], he stated: \r\n\r\n> However, I'd recommend against most other parts of Org, for reasons\r\n> already stated in comments: It's old, and full of legacy and harmful\r\n> practices (e.g. find-file-noselect to read files non-interactively).\r\n\r\nCan anyone explain why is `find-file-noselect` a bad idea to read files in Elisp programs? Is there a better way? I'm asking because I was thinking of using it in one of my projects.\r\n\r\n\r\n [1]: http://emacs.stackexchange.com/questions/145/what-are-some-built-in-packages-with-nice-source-code/151#151\r\n [2]: http://emacs.stackexchange.com/users/227/lunaryorn","link":"http://emacs.stackexchange.com/questions/2868/whats-wrong-with-find-file-noselect","title":"What's wrong with `find-file-noselect`?","body":"<p>In a recent <a href=\"http://emacs.stackexchange.com/questions/145/what-are-some-built-in-packages-with-nice-source-code/151#151\">answer</a> by <a href=\"http://emacs.stackexchange.com/users/227/lunaryorn\">lunaryorn</a>, he stated: </p>\n\n<blockquote>\n <p>However, I'd recommend against most other parts of Org, for reasons\n already stated in comments: It's old, and full of legacy and harmful\n practices (e.g. find-file-noselect to read files non-interactively).</p>\n</blockquote>\n\n<p>Can anyone explain why is <code>find-file-noselect</code> a bad idea to read files in Elisp programs? Is there a better way? I'm asking because I was thinking of using it in one of my projects.</p>\n"},{"answers":[{"owner":{"reputation":860,"user_id":10,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1504319df63de7148c39290d4149f150?s=128&d=identicon&r=PG","display_name":"wasamasa","link":"http://emacs.stackexchange.com/users/10/wasamasa"},"comment_count":0,"is_accepted":false,"score":4,"last_activity_date":1414748894,"creation_date":1414748894,"answer_id":2897,"question_id":2883,"body_markdown":"[comint](http://www.emacswiki.org/emacs/ComintMode)-derived modes (like `shell`, `ielm`, ...) support filter functions, the following snippet makes the output and prompt read-only:\r\n\r\n (defun my-comint-preoutput-turn-buffer-read-only (text)\r\n (propertize text 'read-only t))\r\n\r\n (add-hook 'comint-preoutput-filter-functions 'my-comint-preoutput-turn-buffer-read-only)\r\n\r\nAs for `ansi-term` (which is not derived from [comint](http://www.emacswiki.org/emacs/ComintMode)), it features two modes of operation, `char mode` which stays as truthful to the bindings of the shell and the software running in it as possible and `line mode` which allows you to edit the buffer as you please. You should generally stay in `char mode` (bound to `C-c C-k`) and occasionally switch to `line mode` (bound to `C-c C-j`) for editing command output.","link":"http://emacs.stackexchange.com/questions/2883/any-way-to-make-prompts-and-previous-output-uneditable-in-shell-term-mode/2897#2897","title":"Any way to make prompts and previous-output uneditable in shell/term-mode?","body":"<p><a href=\"http://www.emacswiki.org/emacs/ComintMode\" rel=\"nofollow\">comint</a>-derived modes (like <code>shell</code>, <code>ielm</code>, ...) support filter functions, the following snippet makes the output and prompt read-only:</p>\n\n<pre><code>(defun my-comint-preoutput-turn-buffer-read-only (text)\n (propertize text 'read-only t))\n\n(add-hook 'comint-preoutput-filter-functions 'my-comint-preoutput-turn-buffer-read-only)\n</code></pre>\n\n<p>As for <code>ansi-term</code> (which is not derived from <a href=\"http://www.emacswiki.org/emacs/ComintMode\" rel=\"nofollow\">comint</a>), it features two modes of operation, <code>char mode</code> which stays as truthful to the bindings of the shell and the software running in it as possible and <code>line mode</code> which allows you to edit the buffer as you please. You should generally stay in <code>char mode</code> (bound to <code>C-c C-k</code>) and occasionally switch to <code>line mode</code> (bound to <code>C-c C-j</code>) for editing command output.</p>\n"}],"tags":["shell","ansi-term"],"owner":{"reputation":156,"user_id":2084,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/ab1a56787ee3fc3602592a1909cbd0ea?s=128&d=identicon&r=PG&f=1","display_name":"Dipak C","link":"http://emacs.stackexchange.com/users/2084/dipak-c"},"comments":[{"owner":{"reputation":193,"user_id":215,"user_type":"registered","profile_image":"http://i.stack.imgur.com/y7fBO.png?s=128&g=1","display_name":"Mark Aufflick","link":"http://emacs.stackexchange.com/users/215/mark-aufflick"},"edited":false,"score":0,"post_type":"question","creation_date":1414721113,"post_id":2883,"comment_id":3939,"body_markdown":"Are you on an "odd" OS by any chance? Usually in shell-mode C-a jumps to the start of the commandline, *after* the prompt, and a second C-a is required to jump to the very start. On Windows and Solaris (in a former life) I usually found that C-a jumped to the very start, wheras on MacOS, Linux etc. it works as expected for me.","link":"http://emacs.stackexchange.com/questions/2883/any-way-to-make-prompts-and-previous-output-uneditable-in-shell-term-mode#comment3939_2883","body":"Are you on an "odd" OS by any chance? Usually in shell-mode C-a jumps to the start of the commandline, <i>after</i> the prompt, and a second C-a is required to jump to the very start. On Windows and Solaris (in a former life) I usually found that C-a jumped to the very start, wheras on MacOS, Linux etc. it works as expected for me."},{"owner":{"reputation":156,"user_id":2084,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/ab1a56787ee3fc3602592a1909cbd0ea?s=128&d=identicon&r=PG&f=1","display_name":"Dipak C","link":"http://emacs.stackexchange.com/users/2084/dipak-c"},"reply_to_user":{"reputation":193,"user_id":215,"user_type":"registered","profile_image":"http://i.stack.imgur.com/y7fBO.png?s=128&g=1","display_name":"Mark Aufflick","link":"http://emacs.stackexchange.com/users/215/mark-aufflick"},"edited":false,"score":0,"post_type":"question","creation_date":1414722327,"post_id":2883,"comment_id":3941,"body_markdown":"@Mark A: I've updated the original post to include a few more details, including my current set-up.","link":"http://emacs.stackexchange.com/questions/2883/any-way-to-make-prompts-and-previous-output-uneditable-in-shell-term-mode#comment3941_2883","body":"@Mark A: I've updated the original post to include a few more details, including my current set-up."},{"owner":{"reputation":860,"user_id":10,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1504319df63de7148c39290d4149f150?s=128&d=identicon&r=PG","display_name":"wasamasa","link":"http://emacs.stackexchange.com/users/10/wasamasa"},"edited":false,"score":0,"post_type":"question","creation_date":1414748349,"post_id":2883,"comment_id":3949,"body_markdown":"The described behaviour of ansi-term sounds like you've switched to line mode by either a weird default or `C-c C-j`. Try finding out that default or switch to char mode with `C-c C-k`.","link":"http://emacs.stackexchange.com/questions/2883/any-way-to-make-prompts-and-previous-output-uneditable-in-shell-term-mode#comment3949_2883","body":"The described behaviour of ansi-term sounds like you've switched to line mode by either a weird default or <code>C-c C-j</code>. Try finding out that default or switch to char mode with <code>C-c C-k</code>."},{"owner":{"reputation":472,"user_id":372,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/cb378ba79d85a04a9277ddc0e4259149?s=128&d=identicon&r=PG","display_name":"purple_arrows","link":"http://emacs.stackexchange.com/users/372/purple-arrows"},"edited":false,"score":0,"post_type":"question","creation_date":1414759847,"post_id":2883,"comment_id":3961,"body_markdown":"Since `shell-mode` / `term-mode` respectively do / do not derive from `comint-mode`, you're asking two very different questions at the same time here. Mind splitting this into two separate questions?","link":"http://emacs.stackexchange.com/questions/2883/any-way-to-make-prompts-and-previous-output-uneditable-in-shell-term-mode#comment3961_2883","body":"Since <code>shell-mode</code> / <code>term-mode</code> respectively do / do not derive from <code>comint-mode</code>, you're asking two very different questions at the same time here. Mind splitting this into two separate questions?"}],"last_editor":{"reputation":156,"user_id":2084,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/ab1a56787ee3fc3602592a1909cbd0ea?s=128&d=identicon&r=PG&f=1","display_name":"Dipak C","link":"http://emacs.stackexchange.com/users/2084/dipak-c"},"comment_count":4,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":30,"favorite_count":0,"answer_count":1,"score":1,"last_activity_date":1414748894,"creation_date":1414720518,"last_edit_date":1414722296,"question_id":2883,"body_markdown":"This is admittedly a superficial question.\r\n\r\nAlthough `ansi-term` starts out behaving correctly when I first open it, it seems to degrade into an 'editable' mode after a few commands, e.g., when I do `C-a` (start of line) followed by `C-k` (kill line), it wipes out the whole prompt.\r\n\r\nFor my aesthetic sanity, is there any way to make the prompts and previous output uneditable (for `shell` and `ansi-term`)? \r\n\r\nI'm using zsh in Emacs 24.4; OS is LXDE (Ubuntu 14.04) via Virtual Box.\r\n\r\n(Ideally I'd still be able to move my cursor around...)","link":"http://emacs.stackexchange.com/questions/2883/any-way-to-make-prompts-and-previous-output-uneditable-in-shell-term-mode","title":"Any way to make prompts and previous-output uneditable in shell/term-mode?","body":"<p>This is admittedly a superficial question.</p>\n\n<p>Although <code>ansi-term</code> starts out behaving correctly when I first open it, it seems to degrade into an 'editable' mode after a few commands, e.g., when I do <code>C-a</code> (start of line) followed by <code>C-k</code> (kill line), it wipes out the whole prompt.</p>\n\n<p>For my aesthetic sanity, is there any way to make the prompts and previous output uneditable (for <code>shell</code> and <code>ansi-term</code>)? </p>\n\n<p>I'm using zsh in Emacs 24.4; OS is LXDE (Ubuntu 14.04) via Virtual Box.</p>\n\n<p>(Ideally I'd still be able to move my cursor around...)</p>\n"},{"answers":[{"owner":{"reputation":181,"user_id":943,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/0dcea030535e386eee5821f278d74e3e?s=128&d=identicon&r=PG","display_name":"rimero","link":"http://emacs.stackexchange.com/users/943/rimero"},"comments":[{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"answer","creation_date":1414749291,"post_id":2880,"comment_id":3951,"body_markdown":"@Ryan Notice that the default `helm-boring-file-regexp-list` contains much more than presented here. If you use remiro's setup, notice this point. Probably this is his preference. `helm-input-idle-delay` and `helm-idle-delay default` were 0.01 months ago, to make the fastest possible response. Overall, the setup is fine.","link":"http://emacs.stackexchange.com/questions/2867/how-should-i-change-my-workflow-when-moving-from-ido-to-helm/2880#comment3951_2880","body":"@Ryan Notice that the default <code>helm-boring-file-regexp-list</code> contains much more than presented here. If you use remiro's setup, notice this point. Probably this is his preference. <code>helm-input-idle-delay</code> and <code>helm-idle-delay default</code> were 0.01 months ago, to make the fastest possible response. Overall, the setup is fine."}],"last_editor":{"reputation":181,"user_id":943,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/0dcea030535e386eee5821f278d74e3e?s=128&d=identicon&r=PG","display_name":"rimero","link":"http://emacs.stackexchange.com/users/943/rimero"},"comment_count":1,"is_accepted":true,"score":4,"last_activity_date":1414747262,"last_edit_date":1414747262,"creation_date":1414710893,"answer_id":2880,"question_id":2867,"body_markdown":"I switched from IDO to Helm few years ago and I never looked back.\r\n\r\n- I find the presentation cleaner than let's say ido-vertical-mode for example. \r\n- Helm doesn't have flex matching though.\r\n- You don't need smex, etc. Helm does it all.\r\n- The Tu do article is good as it provides some nice animated screenshots of what Helm can do.\r\n\r\nI use Helm projectile, Helm swoop, Helm semantic, Helm ag and some of the Helm interactive commands. Checkout the [Melpa page][1] for Helm related packages that might interest you.\r\n\r\nHere's some of my Helm related setup :\r\n\r\n \r\n \r\n (setq helm-ff-transformer-show-only-basename nil\r\n helm-adaptive-history-file ers-helm-adaptive-history-file\r\n helm-boring-file-regexp-list '("\\\\.git$" "\\\\.svn$" "\\\\.elc$")\r\n helm-yank-symbol-first t\r\n helm-buffers-fuzzy-matching t\r\n helm-ff-auto-update-initial-value t\r\n helm-input-idle-delay 0.1\r\n helm-idle-delay 0.1)\r\n\r\n (autoload 'helm-descbinds "helm-descbinds" t)\r\n (autoload 'helm-eshell-history "helm-eshell" t)\r\n (autoload 'helm-esh-pcomplete "helm-eshell" t)\r\n\r\n (global-set-key (kbd "C-h a") #'helm-apropos)\r\n (global-set-key (kbd "C-h i") #'helm-info-emacs)\r\n (global-set-key (kbd "C-h b") #'helm-descbinds)\r\n\r\n (add-hook 'eshell-mode-hook\r\n #'(lambda ()\r\n (define-key eshell-mode-map (kbd "TAB") #'helm-esh-pcomplete)\r\n (define-key eshell-mode-map (kbd "C-c C-l") #'helm-eshell-history)))\r\n\r\n (global-set-key (kbd "C-x b") #'helm-mini)\r\n (global-set-key (kbd "C-x C-b") #'helm-buffers-list)\r\n (global-set-key (kbd "C-x C-m") #'helm-M-x)\r\n (global-set-key (kbd "C-x C-f") #'helm-find-files)\r\n (global-set-key (kbd "C-x C-r") #'helm-recentf)\r\n (global-set-key (kbd "C-x r l") #'helm-filtered-bookmarks)\r\n (global-set-key (kbd "M-y") #'helm-show-kill-ring)\r\n (global-set-key (kbd "M-s o") #'helm-swoop)\r\n (global-set-key (kbd "M-s /") #'helm-multi-swoop)\r\n\r\n (require 'helm-config)\r\n (helm-mode t)\r\n (helm-adaptative-mode t)\r\n\r\n (global-set-key (kbd "C-x c!") #'helm-calcul-expression)\r\n (global-set-key (kbd "C-x c:") #'helm-eval-expression-with-eldoc)\r\n (define-key helm-map (kbd "M-o") #'helm-previous-source)\r\n\r\n (global-set-key (kbd "M-s s") #'helm-ag)\r\n\r\n (define-key projectile-mode-map (kbd "C-c p g") \r\n #'(lambda () \r\n (interactive) \r\n (helm-ag (projectile-project-root)))) \r\n\r\n (define-key org-mode-map (kbd "C-x c o h") #'helm-org-headlines) \r\n\r\n\r\n [1]: http://melpa.org/#/","link":"http://emacs.stackexchange.com/questions/2867/how-should-i-change-my-workflow-when-moving-from-ido-to-helm/2880#2880","title":"How should I change my workflow when moving from IDO to Helm","body":"<p>I switched from IDO to Helm few years ago and I never looked back.</p>\n\n<ul>\n<li>I find the presentation cleaner than let's say ido-vertical-mode for example. </li>\n<li>Helm doesn't have flex matching though.</li>\n<li>You don't need smex, etc. Helm does it all.</li>\n<li>The Tu do article is good as it provides some nice animated screenshots of what Helm can do.</li>\n</ul>\n\n<p>I use Helm projectile, Helm swoop, Helm semantic, Helm ag and some of the Helm interactive commands. Checkout the <a href=\"http://melpa.org/#/\" rel=\"nofollow\">Melpa page</a> for Helm related packages that might interest you.</p>\n\n<p>Here's some of my Helm related setup :</p>\n\n<pre><code>(setq helm-ff-transformer-show-only-basename nil\n helm-adaptive-history-file ers-helm-adaptive-history-file\n helm-boring-file-regexp-list '(\"\\\\.git$\" \"\\\\.svn$\" \"\\\\.elc$\")\n helm-yank-symbol-first t\n helm-buffers-fuzzy-matching t\n helm-ff-auto-update-initial-value t\n helm-input-idle-delay 0.1\n helm-idle-delay 0.1)\n\n(autoload 'helm-descbinds \"helm-descbinds\" t)\n(autoload 'helm-eshell-history \"helm-eshell\" t)\n(autoload 'helm-esh-pcomplete \"helm-eshell\" t)\n\n(global-set-key (kbd \"C-h a\") #'helm-apropos)\n(global-set-key (kbd \"C-h i\") #'helm-info-emacs)\n(global-set-key (kbd \"C-h b\") #'helm-descbinds)\n\n(add-hook 'eshell-mode-hook\n #'(lambda ()\n (define-key eshell-mode-map (kbd \"TAB\") #'helm-esh-pcomplete)\n (define-key eshell-mode-map (kbd \"C-c C-l\") #'helm-eshell-history)))\n\n(global-set-key (kbd \"C-x b\") #'helm-mini)\n(global-set-key (kbd \"C-x C-b\") #'helm-buffers-list)\n(global-set-key (kbd \"C-x C-m\") #'helm-M-x)\n(global-set-key (kbd \"C-x C-f\") #'helm-find-files)\n(global-set-key (kbd \"C-x C-r\") #'helm-recentf)\n(global-set-key (kbd \"C-x r l\") #'helm-filtered-bookmarks)\n(global-set-key (kbd \"M-y\") #'helm-show-kill-ring)\n(global-set-key (kbd \"M-s o\") #'helm-swoop)\n(global-set-key (kbd \"M-s /\") #'helm-multi-swoop)\n\n(require 'helm-config)\n(helm-mode t)\n(helm-adaptative-mode t)\n\n(global-set-key (kbd \"C-x c!\") #'helm-calcul-expression)\n(global-set-key (kbd \"C-x c:\") #'helm-eval-expression-with-eldoc)\n(define-key helm-map (kbd \"M-o\") #'helm-previous-source)\n\n(global-set-key (kbd \"M-s s\") #'helm-ag)\n\n(define-key projectile-mode-map (kbd \"C-c p g\") \n #'(lambda () \n (interactive) \n (helm-ag (projectile-project-root)))) \n\n(define-key org-mode-map (kbd \"C-x c o h\") #'helm-org-headlines) \n</code></pre>\n"}],"tags":["helm","ido"],"owner":{"reputation":255,"user_id":35,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/18b80f3021a241d9b85c236dafbcd64b?s=128&d=identicon&r=PG","display_name":"Ryan","link":"http://emacs.stackexchange.com/users/35/ryan"},"comments":[{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":1,"post_type":"question","creation_date":1414748959,"post_id":2867,"comment_id":3950,"body_markdown":"As you already realized, you forgot to bind Helm specific commands to replace the stock Emacs commands. If you keep reading the guides for each specific Helm command, you will see that I put key bindings (if possible) and setup in each section. Nevertheless, enjoy Helm :)","link":"http://emacs.stackexchange.com/questions/2867/how-should-i-change-my-workflow-when-moving-from-ido-to-helm#comment3950_2867","body":"As you already realized, you forgot to bind Helm specific commands to replace the stock Emacs commands. If you keep reading the guides for each specific Helm command, you will see that I put key bindings (if possible) and setup in each section. Nevertheless, enjoy Helm :)"}],"last_editor":{"reputation":1217,"user_id":45,"user_type":"registered","accept_rate":93,"profile_image":"https://www.gravatar.com/avatar/073274c272b84eed27790fc3e5231d46?s=128&d=identicon&r=PG&f=1","display_name":"King Shimkus","link":"http://emacs.stackexchange.com/users/45/king-shimkus"},"comment_count":1,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":89,"favorite_count":2,"accepted_answer_id":2880,"answer_count":1,"score":6,"last_activity_date":1414747262,"creation_date":1414701322,"last_edit_date":1414706239,"question_id":2867,"body_markdown":"As an Emacs newbie, I found IDO and loved it since it made searching for files so much quicker. After spending some time on this site, I've read more and more about Helm and I'm planning on making the switch. Some of my questions are: \r\n\r\n 1. What are the biggest differences? \r\n 2. Specifically, how should my workflow change when finding files, switching buffers, or calling new commands?\r\n\r\nI used [this post](http://tuhdo.github.io/helm-intro.html) to set up Helm, but my file searches (`C-x C-f`) and buffer switches (`C-x b`) look pretty much the same as they did before.\r\n\r\nHere is my config:\r\n\r\n (require 'helm)\r\n (require 'helm-config)\r\n \r\n ;; The default "C-x c" is quite close to "C-x C-c", which quits Emacs.\r\n ;; Changed to "C-c h". Note: We must set "C-c h" globally, because we\r\n ;; cannot change `helm-command-prefix-key' once `helm-config' is loaded.\r\n (global-set-key (kbd "C-c h") 'helm-command-prefix)\r\n (global-unset-key (kbd "C-x c"))\r\n \r\n (define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action) ; rebihnd tab to do persistent action\r\n (define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) ; make TAB works in terminal\r\n (define-key helm-map (kbd "C-z") 'helm-select-action) ; list actions using C-z\r\n \r\n (when (executable-find "curl")\r\n (setq helm-google-suggest-use-curl-p t))\r\n \r\n (setq helm-quick-update t ; do not display invisible candidates\r\n helm-split-window-in-side-p t ; open helm buffer inside current window, not occupy whole other window\r\n helm-buffers-fuzzy-matching t ; fuzzy matching buffer names when non--nil\r\n helm-move-to-line-cycle-in-source t ; move to end or beginning of source when reaching top or bottom of source.\r\n helm-ff-search-library-in-sexp t ; search for library in `require' and `declare-function' sexp.\r\n helm-scroll-amount 8 ; scroll 8 lines other window using M-<next>/M-<prior>\r\n helm-ff-file-name-history-use-recentf t)\r\n \r\n (helm-mode 1)","link":"http://emacs.stackexchange.com/questions/2867/how-should-i-change-my-workflow-when-moving-from-ido-to-helm","title":"How should I change my workflow when moving from IDO to Helm","body":"<p>As an Emacs newbie, I found IDO and loved it since it made searching for files so much quicker. After spending some time on this site, I've read more and more about Helm and I'm planning on making the switch. Some of my questions are: </p>\n\n<ol>\n<li>What are the biggest differences? </li>\n<li>Specifically, how should my workflow change when finding files, switching buffers, or calling new commands?</li>\n</ol>\n\n<p>I used <a href=\"http://tuhdo.github.io/helm-intro.html\">this post</a> to set up Helm, but my file searches (<code>C-x C-f</code>) and buffer switches (<code>C-x b</code>) look pretty much the same as they did before.</p>\n\n<p>Here is my config:</p>\n\n<pre><code>(require 'helm)\n(require 'helm-config)\n\n;; The default \"C-x c\" is quite close to \"C-x C-c\", which quits Emacs.\n;; Changed to \"C-c h\". Note: We must set \"C-c h\" globally, because we\n;; cannot change `helm-command-prefix-key' once `helm-config' is loaded.\n(global-set-key (kbd \"C-c h\") 'helm-command-prefix)\n(global-unset-key (kbd \"C-x c\"))\n\n(define-key helm-map (kbd \"<tab>\") 'helm-execute-persistent-action) ; rebihnd tab to do persistent action\n(define-key helm-map (kbd \"C-i\") 'helm-execute-persistent-action) ; make TAB works in terminal\n(define-key helm-map (kbd \"C-z\") 'helm-select-action) ; list actions using C-z\n\n(when (executable-find \"curl\")\n (setq helm-google-suggest-use-curl-p t))\n\n(setq helm-quick-update t ; do not display invisible candidates\n helm-split-window-in-side-p t ; open helm buffer inside current window, not occupy whole other window\n helm-buffers-fuzzy-matching t ; fuzzy matching buffer names when non--nil\n helm-move-to-line-cycle-in-source t ; move to end or beginning of source when reaching top or bottom of source.\n helm-ff-search-library-in-sexp t ; search for library in `require' and `declare-function' sexp.\n helm-scroll-amount 8 ; scroll 8 lines other window using M-<next>/M-<prior>\n helm-ff-file-name-history-use-recentf t)\n\n(helm-mode 1)\n</code></pre>\n"},{"answers":[{"owner":{"reputation":376,"user_id":2237,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2b6a8e936e696ab9da826075fc1a07de?s=128&d=identicon&r=PG","display_name":"Rémi","link":"http://emacs.stackexchange.com/users/2237/r%c3%a9mi"},"comment_count":0,"is_accepted":false,"score":2,"last_activity_date":1414744957,"creation_date":1414744957,"answer_id":2895,"question_id":2890,"body_markdown":"You can add setting specific to `magit-status` to `magit-status-mode-hook`:\r\n\r\n (defun turn-on-truncate-lines ()\r\n (setq truncate-lines t))\r\n \r\n (add-hook 'magit-status-mode-hook 'turn-on-truncate-lines)\r\n\r\nFor `COMMIT_EDITMSG`, it depend on your version of magit. In version from magit's git next branch, you use text mode with the git-commit-minor-mode on, so you need to add your configuration to `git-commit-mode-hook`\r\n\r\n (add-hook 'git-commit-mode-hook 'turn-off-auto-fill)\r\n\r\nWith other version of magit, or with other configuration, you might be using another mode for editing COMMIT_EDITMSG. Use `C-h m` to find which, and add `-hook` to its name to find what you hook should be added to.\r\n\r\n(turn-off-auto-fill is already define, no need to define it). \r\n\r\nPs: you didn't want it, but I add it for completness: the magit-mode-hook exist for setting configuration available in most magit's mode (log, show commit, ....)\r\n","link":"http://emacs.stackexchange.com/questions/2890/how-to-make-truncate-lines-nil-and-auto-fill-mode-off-in-magit-buffers/2895#2895","title":"How to make `truncate-lines` nil and `auto-fill-mode` off in magit buffers","body":"<p>You can add setting specific to <code>magit-status</code> to <code>magit-status-mode-hook</code>:</p>\n\n<pre><code>(defun turn-on-truncate-lines ()\n (setq truncate-lines t))\n\n(add-hook 'magit-status-mode-hook 'turn-on-truncate-lines)\n</code></pre>\n\n<p>For <code>COMMIT_EDITMSG</code>, it depend on your version of magit. In version from magit's git next branch, you use text mode with the git-commit-minor-mode on, so you need to add your configuration to <code>git-commit-mode-hook</code></p>\n\n<pre><code>(add-hook 'git-commit-mode-hook 'turn-off-auto-fill)\n</code></pre>\n\n<p>With other version of magit, or with other configuration, you might be using another mode for editing COMMIT_EDITMSG. Use <code>C-h m</code> to find which, and add <code>-hook</code> to its name to find what you hook should be added to.</p>\n\n<p>(turn-off-auto-fill is already define, no need to define it). </p>\n\n<p>Ps: you didn't want it, but I add it for completness: the magit-mode-hook exist for setting configuration available in most magit's mode (log, show commit, ....)</p>\n"}],"tags":["magit"],"owner":{"reputation":123,"user_id":794,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/9e0131ea359bc35a9902fc03d8ac7155?s=128&d=identicon&r=PG&f=1","display_name":"CodyChan","link":"http://emacs.stackexchange.com/users/794/codychan"},"comment_count":0,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":16,"favorite_count":0,"answer_count":1,"score":0,"last_activity_date":1414744957,"creation_date":1414730361,"question_id":2890,"body_markdown":"I got \r\n\r\n (setq-default fill-column 80)\r\n (setq-default truncate-lines nil) ;; which is default\r\n\r\n\r\nWhen using magit in Emacs, I know that I should avoid long commit messages, but sometimes they just cannot be avoid. \r\n\r\nThe problem is: `(setq-default truncate-lines nil)` which is default setting does not work in **magit: project** buffer(there is a straight right arrow at the end of line) but work in **COMMIT_EDITMSG** buffer, the `(setq-default fill-column 80)` does not work in **COMMIT_EDITMSG** buffer, the `fill-column` value in it is 72 not 80.\r\n\r\nBut what I really want is: make the `truncate-lines` to `nil` in **magit: project** buffer too so I can see long lines in one window but not break it into several lines, **AND** turn all auto-fill-mode in **COMMIT_EDITMSG** buffer, so long commit messages won't be broken into several lines when I'm typing.\r\n\r\nNOTE: DO NOT affect other buffers like **magit-log** buffer","link":"http://emacs.stackexchange.com/questions/2890/how-to-make-truncate-lines-nil-and-auto-fill-mode-off-in-magit-buffers","title":"How to make `truncate-lines` nil and `auto-fill-mode` off in magit buffers","body":"<p>I got </p>\n\n<pre><code>(setq-default fill-column 80)\n(setq-default truncate-lines nil) ;; which is default\n</code></pre>\n\n<p>When using magit in Emacs, I know that I should avoid long commit messages, but sometimes they just cannot be avoid. </p>\n\n<p>The problem is: <code>(setq-default truncate-lines nil)</code> which is default setting does not work in <strong>magit: project</strong> buffer(there is a straight right arrow at the end of line) but work in <strong>COMMIT_EDITMSG</strong> buffer, the <code>(setq-default fill-column 80)</code> does not work in <strong>COMMIT_EDITMSG</strong> buffer, the <code>fill-column</code> value in it is 72 not 80.</p>\n\n<p>But what I really want is: make the <code>truncate-lines</code> to <code>nil</code> in <strong>magit: project</strong> buffer too so I can see long lines in one window but not break it into several lines, <strong>AND</strong> turn all auto-fill-mode in <strong>COMMIT_EDITMSG</strong> buffer, so long commit messages won't be broken into several lines when I'm typing.</p>\n\n<p>NOTE: DO NOT affect other buffers like <strong>magit-log</strong> buffer</p>\n"},{"answers":[{"owner":{"reputation":144,"user_id":2287,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5f4ed4b573c4e38444c6fc54b28076c0?s=128&d=identicon&r=PG","display_name":"lawlist","link":"http://emacs.stackexchange.com/users/2287/lawlist"},"comment_count":0,"is_accepted":false,"score":1,"last_activity_date":1414742131,"creation_date":1414742131,"answer_id":2894,"question_id":2881,"body_markdown":"The following is just a tweak to Dired+ -- adopting the same manner to highlight folder extensions as is already done with file extensions; with the additional tweak to the beginning regexp to get me over to the files / folders. My custom time-style of `ls` is not compatible with dired-mode or the corresponding regexp in files.el, so I composed my own regexp. The section below relating to `diredp-font-lock-keywords-1` is just the relevant excerpt.\r\n\r\nOver the next few days, I'll continue to think about the regexp proposed by @Malabarba `.*\\\\(\\\\.[^.]*\\\\)$` to see if I can create a whopper regexp that covers the majority of situations. I ended up with about 5 different regexp strings, which is not as clean as Dired+ presently offers.\r\n\r\n\r\n <!-- language: lang-lisp -->\r\n\r\n (defvar folder-listing-before-filename-regexp\r\n (concat\r\n "\\\\(^ +d[slrwxt+-]+\\\\)" ;; 1 permissions\r\n "\\\\(\\s\\\\)" ;; 2\r\n "\\\\([0-9]+\\\\|\\s+[0-9]+\\\\)" ;; 3 some small numbers\r\n "\\\\(\\s\\\\)" ;; 4\r\n "\\\\([a-zA-Z]+\\\\)" ;; 5 user\r\n "\\\\(\\s\\\\)" ;; 6\r\n "\\\\([a-zA-Z]+\\\\)" ;; 7 group\r\n "\\\\(\\s\\\\)" ;; 8\r\n "\\\\([\\s0-9.kKMGT]+\\\\)" ;; 9 size\r\n "\\\\(\\s\\\\)" ;; 10\r\n "\\\\([0-9-]+\\\\)" ;; 11 date\r\n "\\\\(\\s\\\\)" ;; 12\r\n "\\\\([0-9:]+\\\\)" ;; 13 time\r\n "\\\\(\\s\\\\)")) ;; 14\r\n \r\n (defvar file-listing-before-filename-regexp\r\n (concat\r\n "\\\\(^ +[^d][slrwxt+-]+\\\\)" ;; 1 permissions\r\n "\\\\(\\s\\\\)" ;; 2\r\n "\\\\([0-9]+\\\\|\\s+[0-9]+\\\\)" ;; 3 some small numbers\r\n "\\\\(\\s\\\\)" ;; 4\r\n "\\\\([a-zA-Z]+\\\\)" ;; 5 user\r\n "\\\\(\\s\\\\)" ;; 6\r\n "\\\\([a-zA-Z]+\\\\)" ;; 7 group\r\n "\\\\(\\s\\\\)" ;; 8\r\n "\\\\([\\s0-9.kKMGT]+\\\\)" ;; 9 size\r\n "\\\\(\\s\\\\)" ;; 10\r\n "\\\\([0-9-]+\\\\)" ;; 11 date\r\n "\\\\(\\s\\\\)" ;; 12\r\n "\\\\([0-9:]+\\\\)" ;; 13 time\r\n "\\\\(\\s\\\\)")) ;; 14\r\n \r\n (defvar diredp-font-lock-keywords-1\r\n (list\r\n '("[^ .]\\\\.\\\\(git\\\\)$" 1 'diredp-git-face t)\r\n '("[^ .]\\\\.\\\\(app\\\\)$" 1 'diredp-app-face t)\r\n \r\n (list folder-listing-before-filename-regexp\r\n (list "\\\\(.+\\\\)$" nil nil (list 0 diredp-dir-priv 'keep t))) ; folder-name\r\n \r\n (list file-listing-before-filename-regexp\r\n (list "\\\\(.+\\\\)$" nil nil (list 0 diredp-file-name 'keep t))) ; file-name\r\n ))","link":"http://emacs.stackexchange.com/questions/2881/composing-a-regexp-to-highlight-folder-extensions-differently/2894#2894","title":"Composing a regexp to highlight folder extensions differently","body":"<p>The following is just a tweak to Dired+ -- adopting the same manner to highlight folder extensions as is already done with file extensions; with the additional tweak to the beginning regexp to get me over to the files / folders. My custom time-style of <code>ls</code> is not compatible with dired-mode or the corresponding regexp in files.el, so I composed my own regexp. The section below relating to <code>diredp-font-lock-keywords-1</code> is just the relevant excerpt.</p>\n\n<p>Over the next few days, I'll continue to think about the regexp proposed by @Malabarba <code>.*\\\\(\\\\.[^.]*\\\\)$</code> to see if I can create a whopper regexp that covers the majority of situations. I ended up with about 5 different regexp strings, which is not as clean as Dired+ presently offers.</p>\n\n \n\n<pre><code>(defvar folder-listing-before-filename-regexp\n (concat\n \"\\\\(^ +d[slrwxt+-]+\\\\)\" ;; 1 permissions\n \"\\\\(\\s\\\\)\" ;; 2\n \"\\\\([0-9]+\\\\|\\s+[0-9]+\\\\)\" ;; 3 some small numbers\n \"\\\\(\\s\\\\)\" ;; 4\n \"\\\\([a-zA-Z]+\\\\)\" ;; 5 user\n \"\\\\(\\s\\\\)\" ;; 6\n \"\\\\([a-zA-Z]+\\\\)\" ;; 7 group\n \"\\\\(\\s\\\\)\" ;; 8\n \"\\\\([\\s0-9.kKMGT]+\\\\)\" ;; 9 size\n \"\\\\(\\s\\\\)\" ;; 10\n \"\\\\([0-9-]+\\\\)\" ;; 11 date\n \"\\\\(\\s\\\\)\" ;; 12\n \"\\\\([0-9:]+\\\\)\" ;; 13 time\n \"\\\\(\\s\\\\)\")) ;; 14\n\n(defvar file-listing-before-filename-regexp\n (concat\n \"\\\\(^ +[^d][slrwxt+-]+\\\\)\" ;; 1 permissions\n \"\\\\(\\s\\\\)\" ;; 2\n \"\\\\([0-9]+\\\\|\\s+[0-9]+\\\\)\" ;; 3 some small numbers\n \"\\\\(\\s\\\\)\" ;; 4\n \"\\\\([a-zA-Z]+\\\\)\" ;; 5 user\n \"\\\\(\\s\\\\)\" ;; 6\n \"\\\\([a-zA-Z]+\\\\)\" ;; 7 group\n \"\\\\(\\s\\\\)\" ;; 8\n \"\\\\([\\s0-9.kKMGT]+\\\\)\" ;; 9 size\n \"\\\\(\\s\\\\)\" ;; 10\n \"\\\\([0-9-]+\\\\)\" ;; 11 date\n \"\\\\(\\s\\\\)\" ;; 12\n \"\\\\([0-9:]+\\\\)\" ;; 13 time\n \"\\\\(\\s\\\\)\")) ;; 14\n\n(defvar diredp-font-lock-keywords-1\n (list\n '(\"[^ .]\\\\.\\\\(git\\\\)$\" 1 'diredp-git-face t)\n '(\"[^ .]\\\\.\\\\(app\\\\)$\" 1 'diredp-app-face t)\n\n (list folder-listing-before-filename-regexp\n (list \"\\\\(.+\\\\)$\" nil nil (list 0 diredp-dir-priv 'keep t))) ; folder-name\n\n (list file-listing-before-filename-regexp\n (list \"\\\\(.+\\\\)$\" nil nil (list 0 diredp-file-name 'keep t))) ; file-name\n ))\n</code></pre>\n"}],"tags":["dired","regular-expressions"],"owner":{"reputation":144,"user_id":2287,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5f4ed4b573c4e38444c6fc54b28076c0?s=128&d=identicon&r=PG","display_name":"lawlist","link":"http://emacs.stackexchange.com/users/2287/lawlist"},"comments":[{"owner":{"reputation":1217,"user_id":45,"user_type":"registered","accept_rate":93,"profile_image":"https://www.gravatar.com/avatar/073274c272b84eed27790fc3e5231d46?s=128&d=identicon&r=PG&f=1","display_name":"King Shimkus","link":"http://emacs.stackexchange.com/users/45/king-shimkus"},"edited":false,"score":0,"post_type":"question","creation_date":1414715005,"post_id":2881,"comment_id":3933,"body_markdown":"Have you tried looking into other options? Such as [Dired+](http://www.emacswiki.org/DiredPlus)?","link":"http://emacs.stackexchange.com/questions/2881/composing-a-regexp-to-highlight-folder-extensions-differently#comment3933_2881","body":"Have you tried looking into other options? Such as <a href=\"http://www.emacswiki.org/DiredPlus\" rel=\"nofollow\">Dired+</a>?"},{"owner":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":0,"post_type":"question","creation_date":1414715050,"post_id":2881,"comment_id":3934,"body_markdown":"Why would `[^.]*` prevent you from using the dot? Something like `[^.]*\\\\(\\\\..*\\\\)` should match your request and group the entire extension including the dot. Show us what you've tried.","link":"http://emacs.stackexchange.com/questions/2881/composing-a-regexp-to-highlight-folder-extensions-differently#comment3934_2881","body":"Why would <code>[^.]*</code> prevent you from using the dot? Something like <code>[^.]*\\\\(\\\\..*\\\\)</code> should match your request and group the entire extension including the dot. Show us what you've tried."},{"owner":{"reputation":144,"user_id":2287,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5f4ed4b573c4e38444c6fc54b28076c0?s=128&d=identicon&r=PG","display_name":"lawlist","link":"http://emacs.stackexchange.com/users/2287/lawlist"},"reply_to_user":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":0,"post_type":"question","creation_date":1414715279,"post_id":2881,"comment_id":3935,"body_markdown":"@Malabarba -- your suggestion almost does it, with the exception of the folders beginning with a dot -- e.g., `.0.context-menu.git` I'll work on it a little later on this evening using your example as a starting point.","link":"http://emacs.stackexchange.com/questions/2881/composing-a-regexp-to-highlight-folder-extensions-differently#comment3935_2881","body":"@Malabarba -- your suggestion almost does it, with the exception of the folders beginning with a dot -- e.g., <code>.0.context-menu.git</code> I'll work on it a little later on this evening using your example as a starting point."},{"owner":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":0,"post_type":"question","creation_date":1414715491,"post_id":2881,"comment_id":3936,"body_markdown":"I see. And does `.*\\\\(\\\\.[^.]*\\\\)$` not work either? (I'm not at the pc right now so I can't test myself).","link":"http://emacs.stackexchange.com/questions/2881/composing-a-regexp-to-highlight-folder-extensions-differently#comment3936_2881","body":"I see. And does <code>.*\\\\(\\\\.[^.]*\\\\)$</code> not work either? (I'm not at the pc right now so I can't test myself)."},{"owner":{"reputation":144,"user_id":2287,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5f4ed4b573c4e38444c6fc54b28076c0?s=128&d=identicon&r=PG","display_name":"lawlist","link":"http://emacs.stackexchange.com/users/2287/lawlist"},"reply_to_user":{"reputation":1217,"user_id":45,"user_type":"registered","accept_rate":93,"profile_image":"https://www.gravatar.com/avatar/073274c272b84eed27790fc3e5231d46?s=128&d=identicon&r=PG&f=1","display_name":"King Shimkus","link":"http://emacs.stackexchange.com/users/45/king-shimkus"},"edited":false,"score":0,"post_type":"question","creation_date":1414715505,"post_id":2881,"comment_id":3937,"body_markdown":"@King Shimkus -- yes, thank you -- the regex for the permission colors and file size are from Dired+, but I broke some of the functionality by adding a custom time-style. My custom time-style is also not compatible with `directory-listing-before-filename-regexp`. Dired mode is not designed for a custom time-style like the one I'm using, so I'm essentially creating a custom version of dired-mode.","link":"http://emacs.stackexchange.com/questions/2881/composing-a-regexp-to-highlight-folder-extensions-differently#comment3937_2881","body":"@King Shimkus -- yes, thank you -- the regex for the permission colors and file size are from Dired+, but I broke some of the functionality by adding a custom time-style. My custom time-style is also not compatible with <code>directory-listing-before-filename-regexp</code>. Dired mode is not designed for a custom time-style like the one I'm using, so I'm essentially creating a custom version of dired-mode."},{"owner":{"reputation":144,"user_id":2287,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5f4ed4b573c4e38444c6fc54b28076c0?s=128&d=identicon&r=PG","display_name":"lawlist","link":"http://emacs.stackexchange.com/users/2287/lawlist"},"reply_to_user":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":0,"post_type":"question","creation_date":1414715687,"post_id":2881,"comment_id":3938,"body_markdown":"@Malabarba -- Yes, I think that does it! I'll report back later this evening when I've done a little more testing. Thank you.","link":"http://emacs.stackexchange.com/questions/2881/composing-a-regexp-to-highlight-folder-extensions-differently#comment3938_2881","body":"@Malabarba -- Yes, I think that does it! I'll report back later this evening when I've done a little more testing. Thank you."},{"owner":{"reputation":144,"user_id":2287,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5f4ed4b573c4e38444c6fc54b28076c0?s=128&d=identicon&r=PG","display_name":"lawlist","link":"http://emacs.stackexchange.com/users/2287/lawlist"},"reply_to_user":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":0,"post_type":"question","creation_date":1414735370,"post_id":2881,"comment_id":3942,"body_markdown":"@Malabarba -- I have a working draft of a few categories with slightly different regexp for each category, and a catch-all category that incorporates a custom list consisting of anything not previously handled. However, I have not yet been able to compose one whopper regexp for all situations -- e.g., `\\\\(?:stuff\\\\(more-stuff\\\\)\\\\)?\\\\(?:misc\\\\(more-misc\\\\)\\\\)?$`. I'd like to please leave this thread open for a couple of days to do some more experimenting and then post a working draft as an edit to my question. Thanks again for putting me on the right track -- greatly appreciated! :)","link":"http://emacs.stackexchange.com/questions/2881/composing-a-regexp-to-highlight-folder-extensions-differently#comment3942_2881","body":"@Malabarba -- I have a working draft of a few categories with slightly different regexp for each category, and a catch-all category that incorporates a custom list consisting of anything not previously handled. However, I have not yet been able to compose one whopper regexp for all situations -- e.g., <code>\\\\(?:stuff\\\\(more-stuff\\\\)\\\\)?\\\\(?:misc\\\\(more-misc\\\\)\\\\)?$</code>. I'd like to please leave this thread open for a couple of days to do some more experimenting and then post a working draft as an edit to my question. Thanks again for putting me on the right track -- greatly appreciated! :)"},{"owner":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":0,"post_type":"question","creation_date":1414753681,"post_id":2881,"comment_id":3957,"body_markdown":"@lawlist I may be wrong, but it looks like you're using question marks when you actually need a `\\\\|`.","link":"http://emacs.stackexchange.com/questions/2881/composing-a-regexp-to-highlight-folder-extensions-differently#comment3957_2881","body":"@lawlist I may be wrong, but it looks like you're using question marks when you actually need a <code>\\\\|</code>."},{"owner":{"reputation":144,"user_id":2287,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5f4ed4b573c4e38444c6fc54b28076c0?s=128&d=identicon&r=PG","display_name":"lawlist","link":"http://emacs.stackexchange.com/users/2287/lawlist"},"reply_to_user":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":0,"post_type":"question","creation_date":1414772949,"post_id":2881,"comment_id":3994,"body_markdown":"@Malabarba -- I was hoping to do something like 15 (if matched) will be red, 16 (if matched) will be blue, 17 (if matched) will be green, and so on. If I use `\\\\|`, then they will all be the same color -- unless it's somehow possible to use `\\\\(something\\\\)` in conjunction with `\\\\|` -- I've never seen an example that uses both. However, my initial attempts at putting possible matches with question marks haven't worked.","link":"http://emacs.stackexchange.com/questions/2881/composing-a-regexp-to-highlight-folder-extensions-differently#comment3994_2881","body":"@Malabarba -- I was hoping to do something like 15 (if matched) will be red, 16 (if matched) will be blue, 17 (if matched) will be green, and so on. If I use <code>\\\\|</code>, then they will all be the same color -- unless it's somehow possible to use <code>\\\\(something\\\\)</code> in conjunction with <code>\\\\|</code> -- I've never seen an example that uses both. However, my initial attempts at putting possible matches with question marks haven't worked."}],"comment_count":9,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":29,"favorite_count":0,"answer_count":1,"score":3,"last_activity_date":1414742131,"creation_date":1414714432,"question_id":2881,"body_markdown":"I am having difficulties composing a regexp that will highlight certain *folder* extensions -- **including the preceding dot** -- with colors that are different than the rest of the folder -- e.g., `.app` would be colored red; and `.git` would be colored blue.\r\n\r\nExamples:\r\n\r\n* The folder `Emacs.app` would be colorized with `Emacs` being a gray color and `.app` would be a red color.\r\n\r\n* The folder `.0.context-menu.git` would be colorized with `.0.context-menu` being a gray color and `.git` would be a blue color.\r\n\r\nI have a regexp that gets me from the left margin all the way to the beginning of the folder -- the variable for that regexp is named `folder-listing-before-filename-regexp`.\r\n\r\nThe problem I am having is that the regex `.*` swallows up the folder extensions. If I add `[^.]`, that prevents me from using the dot later on with extensions like `.app` and `.git` -- I want the extension to include the dot when colored.\r\n\r\nThe regexp that leads up to the folder looks like this:\r\n\r\n (defvar folder-listing-before-filename-regexp\r\n (concat\r\n "\\\\(^ +d[slrwxt+-]+\\\\)" ;; 1 permissions\r\n "\\\\(\\s\\\\)" ;; 2\r\n "\\\\([0-9]+\\\\|\\s+[0-9]+\\\\)" ;; 3 some small numbers\r\n "\\\\(\\s\\\\)" ;; 4\r\n "\\\\([a-zA-Z]+\\\\)" ;; 5 group\r\n "\\\\(\\s\\\\)" ;; 6\r\n "\\\\([a-zA-Z]+\\\\)" ;; 7 user\r\n "\\\\(\\s\\\\)" ;; 8\r\n "\\\\([\\s0-9.kKMGT]+\\\\)" ;; 9 size\r\n "\\\\(\\s\\\\)" ;; 10\r\n "\\\\([0-9-]+\\\\)" ;; 11 date\r\n "\\\\(\\s\\\\)" ;; 12\r\n "\\\\([0-9:]+\\\\)" ;; 13 time\r\n "\\\\(\\s\\\\)")) ;; 14\r\n\r\nHere is some test data:\r\n\r\n drwxr-xr-x 79 HOME staff 2.7K 10-30-2014 16:42:18 .\r\n drwxr-xr-x 27 HOME staff 918 10-28-2014 13:08:59 ..\r\n drwxr-xr-x 162 HOME staff 5.4K 10-11-2014 11:34:16 .0.apel_flim_simi\r\n drwxr-xr-x 432 HOME staff 15K 10-29-2014 15:37:44 .0.backup\r\n drwxr-xr-x 5 HOME staff 170 10-19-2014 09:34:37 .0.context-menu.git\r\n drwxr-xr-x 5 HOME staff 170 10-19-2014 13:06:36 .0.dired-read-filename.git\r\n drwx------ 4 HOME staff 136 04-29-2014 17:40:13 .0.eshell\r\n drwxr-xr-x 3 HOME staff 102 10-11-2014 10:29:03 .0.gh\r\n drwxr-xr-x 5 HOME staff 170 10-09-2014 21:16:35 .0.lorg-calendar.git\r\n drwxr-xr-x 5 HOME staff 170 10-09-2014 20:06:09 .0.lorg-search.git\r\n drwxr-xr-x 10 HOME staff 340 01-31-2014 19:37:31 .0.mail\r\n drwxr-xr-x 25 HOME staff 850 10-14-2014 13:23:31 .0.snippets\r\n drwxr-xr-x 23 HOME staff 782 12-03-2013 17:15:50 .0.sound\r\n drwxr-xr-x 27 HOME staff 918 10-18-2014 11:53:56 .0.sources\r\n drwxr-xr-x 67 HOME staff 2.3K 05-05-2014 23:19:12 .0.w3m\r\n drwxr-xr-x 146 HOME staff 4.9K 09-08-2014 10:54:40 .0.wl\r\n drwxr-xr-x 3 HOME staff 102 06-03-2014 11:37:02 Emacs.app\r\n drwxr-xr-x 3 HOME staff 102 06-01-2014 10:39:02 Emacs_06_01_2014.app\r\n drwxr-xr-x 3 HOME staff 102 10-01-2014 07:31:45 Emacs_10_01_2014.app\r\n drwxr-xr-x 195 HOME staff 6.5K 10-18-2014 12:06:25 bin\r\n drwxr-xr-x 3 HOME staff 102 06-26-2013 07:59:44 etc\r\n drwxr-xr-x 10 HOME staff 340 09-30-2014 18:07:42 include\r\n drwxr-xr-x 9 HOME staff 306 06-05-2013 22:50:05 info\r\n drwxr-xr-x 27 HOME staff 918 10-18-2014 12:06:42 lib\r\n drwxr-xr-x 12 HOME staff 408 09-30-2014 18:10:42 libexec\r\n drwxr-xr-x 4 root staff 136 09-30-2014 18:07:42 man\r\n drwxr-xr-x 4 root staff 136 09-30-2014 18:10:42 sbin\r\n drwxr-xr-x 9 HOME staff 306 09-30-2014 18:10:42 share\r\n\r\n\r\n\r\n","link":"http://emacs.stackexchange.com/questions/2881/composing-a-regexp-to-highlight-folder-extensions-differently","title":"Composing a regexp to highlight folder extensions differently","body":"<p>I am having difficulties composing a regexp that will highlight certain <em>folder</em> extensions -- <strong>including the preceding dot</strong> -- with colors that are different than the rest of the folder -- e.g., <code>.app</code> would be colored red; and <code>.git</code> would be colored blue.</p>\n\n<p>Examples:</p>\n\n<ul>\n<li><p>The folder <code>Emacs.app</code> would be colorized with <code>Emacs</code> being a gray color and <code>.app</code> would be a red color.</p></li>\n<li><p>The folder <code>.0.context-menu.git</code> would be colorized with <code>.0.context-menu</code> being a gray color and <code>.git</code> would be a blue color.</p></li>\n</ul>\n\n<p>I have a regexp that gets me from the left margin all the way to the beginning of the folder -- the variable for that regexp is named <code>folder-listing-before-filename-regexp</code>.</p>\n\n<p>The problem I am having is that the regex <code>.*</code> swallows up the folder extensions. If I add <code>[^.]</code>, that prevents me from using the dot later on with extensions like <code>.app</code> and <code>.git</code> -- I want the extension to include the dot when colored.</p>\n\n<p>The regexp that leads up to the folder looks like this:</p>\n\n<pre><code>(defvar folder-listing-before-filename-regexp\n (concat\n \"\\\\(^ +d[slrwxt+-]+\\\\)\" ;; 1 permissions\n \"\\\\(\\s\\\\)\" ;; 2\n \"\\\\([0-9]+\\\\|\\s+[0-9]+\\\\)\" ;; 3 some small numbers\n \"\\\\(\\s\\\\)\" ;; 4\n \"\\\\([a-zA-Z]+\\\\)\" ;; 5 group\n \"\\\\(\\s\\\\)\" ;; 6\n \"\\\\([a-zA-Z]+\\\\)\" ;; 7 user\n \"\\\\(\\s\\\\)\" ;; 8\n \"\\\\([\\s0-9.kKMGT]+\\\\)\" ;; 9 size\n \"\\\\(\\s\\\\)\" ;; 10\n \"\\\\([0-9-]+\\\\)\" ;; 11 date\n \"\\\\(\\s\\\\)\" ;; 12\n \"\\\\([0-9:]+\\\\)\" ;; 13 time\n \"\\\\(\\s\\\\)\")) ;; 14\n</code></pre>\n\n<p>Here is some test data:</p>\n\n<pre><code> drwxr-xr-x 79 HOME staff 2.7K 10-30-2014 16:42:18 .\n drwxr-xr-x 27 HOME staff 918 10-28-2014 13:08:59 ..\n drwxr-xr-x 162 HOME staff 5.4K 10-11-2014 11:34:16 .0.apel_flim_simi\n drwxr-xr-x 432 HOME staff 15K 10-29-2014 15:37:44 .0.backup\n drwxr-xr-x 5 HOME staff 170 10-19-2014 09:34:37 .0.context-menu.git\n drwxr-xr-x 5 HOME staff 170 10-19-2014 13:06:36 .0.dired-read-filename.git\n drwx------ 4 HOME staff 136 04-29-2014 17:40:13 .0.eshell\n drwxr-xr-x 3 HOME staff 102 10-11-2014 10:29:03 .0.gh\n drwxr-xr-x 5 HOME staff 170 10-09-2014 21:16:35 .0.lorg-calendar.git\n drwxr-xr-x 5 HOME staff 170 10-09-2014 20:06:09 .0.lorg-search.git\n drwxr-xr-x 10 HOME staff 340 01-31-2014 19:37:31 .0.mail\n drwxr-xr-x 25 HOME staff 850 10-14-2014 13:23:31 .0.snippets\n drwxr-xr-x 23 HOME staff 782 12-03-2013 17:15:50 .0.sound\n drwxr-xr-x 27 HOME staff 918 10-18-2014 11:53:56 .0.sources\n drwxr-xr-x 67 HOME staff 2.3K 05-05-2014 23:19:12 .0.w3m\n drwxr-xr-x 146 HOME staff 4.9K 09-08-2014 10:54:40 .0.wl\n drwxr-xr-x 3 HOME staff 102 06-03-2014 11:37:02 Emacs.app\n drwxr-xr-x 3 HOME staff 102 06-01-2014 10:39:02 Emacs_06_01_2014.app\n drwxr-xr-x 3 HOME staff 102 10-01-2014 07:31:45 Emacs_10_01_2014.app\n drwxr-xr-x 195 HOME staff 6.5K 10-18-2014 12:06:25 bin\n drwxr-xr-x 3 HOME staff 102 06-26-2013 07:59:44 etc\n drwxr-xr-x 10 HOME staff 340 09-30-2014 18:07:42 include\n drwxr-xr-x 9 HOME staff 306 06-05-2013 22:50:05 info\n drwxr-xr-x 27 HOME staff 918 10-18-2014 12:06:42 lib\n drwxr-xr-x 12 HOME staff 408 09-30-2014 18:10:42 libexec\n drwxr-xr-x 4 root staff 136 09-30-2014 18:07:42 man\n drwxr-xr-x 4 root staff 136 09-30-2014 18:10:42 sbin\n drwxr-xr-x 9 HOME staff 306 09-30-2014 18:10:42 share\n</code></pre>\n\n<p><img src=\"http://www.lawlist.com/images/dired_font_lock.png\" alt=\"Example\"></p>\n"},{"answers":[{"owner":{"reputation":376,"user_id":2237,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2b6a8e936e696ab9da826075fc1a07de?s=128&d=identicon&r=PG","display_name":"Rémi","link":"http://emacs.stackexchange.com/users/2237/r%c3%a9mi"},"comment_count":0,"is_accepted":true,"score":3,"last_activity_date":1414736153,"creation_date":1414736153,"answer_id":2892,"question_id":2860,"body_markdown":"`imenu-generic-expression` is a buffer local variable. When opening a new buffer, imenu will set imenu-generic-expression local value to something interesting for the current buffer. So setting imenu-generic-expression in init won't be useful, as its default-value is never used.\r\n\r\nWhat you want to set is the variable that it used by imenu for setting imenu-generic-expression in `emacs-lisp-mode`. It seem that it is the value from `lisp-imenu-generic-expression`, that is define in `lisp-mode`. So you just have to:\r\n\r\n (with-eval-after-load 'lisp-mode\r\n (setq lisp-imenu-generic-expression (copy-sequence `(,@dc-additions ,@lisp-imenu-generic-expression))))\r\n\r\nNote that you must eval the `setq lisp-imenu-generic-expression` in a `with-eval-after-load` because you depend on the default value of `lisp-imenu-generic-expression` that won't be known to Emacs before lisp-mode is loaded. \r\n","link":"http://emacs.stackexchange.com/questions/2860/how-to-force-evaluation-of-a-statement-in-my-init-file/2892#2892","title":"How to force evaluation of a statement in my `init` file?","body":"<p><code>imenu-generic-expression</code> is a buffer local variable. When opening a new buffer, imenu will set imenu-generic-expression local value to something interesting for the current buffer. So setting imenu-generic-expression in init won't be useful, as its default-value is never used.</p>\n\n<p>What you want to set is the variable that it used by imenu for setting imenu-generic-expression in <code>emacs-lisp-mode</code>. It seem that it is the value from <code>lisp-imenu-generic-expression</code>, that is define in <code>lisp-mode</code>. So you just have to:</p>\n\n<pre><code>(with-eval-after-load 'lisp-mode\n (setq lisp-imenu-generic-expression (copy-sequence `(,@dc-additions ,@lisp-imenu-generic-expression))))\n</code></pre>\n\n<p>Note that you must eval the <code>setq lisp-imenu-generic-expression</code> in a <code>with-eval-after-load</code> because you depend on the default value of <code>lisp-imenu-generic-expression</code> that won't be known to Emacs before lisp-mode is loaded. </p>\n"}],"tags":["elisp","helm"],"owner":{"reputation":156,"user_id":2084,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/ab1a56787ee3fc3602592a1909cbd0ea?s=128&d=identicon&r=PG&f=1","display_name":"Dipak C","link":"http://emacs.stackexchange.com/users/2084/dipak-c"},"comments":[{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414690376,"post_id":2860,"comment_id":3908,"body_markdown":"Could you try `helm-imenu` alone? `helm-semantic-or-imenu`, as its name suggests, use either semantic **or** imenu. If the command has candidates from `helm-semantic`, it won't display imenu's candidates, unless the candidates from `helm-semantic` is `nil`. There's also a stand alone `helm-semantic`. The advantage of `helm-semantic` is that it provides more information, so you can look thing like function interface and preselect the candidate when run `helm-semantic`. But Imenu is easier to extend without touching Semantic parser.","link":"http://emacs.stackexchange.com/questions/2860/how-to-force-evaluation-of-a-statement-in-my-init-file#comment3908_2860","body":"Could you try <code>helm-imenu</code> alone? <code>helm-semantic-or-imenu</code>, as its name suggests, use either semantic <b>or</b> imenu. If the command has candidates from <code>helm-semantic</code>, it won't display imenu's candidates, unless the candidates from <code>helm-semantic</code> is <code>nil</code>. There's also a stand alone <code>helm-semantic</code>. The advantage of <code>helm-semantic</code> is that it provides more information, so you can look thing like function interface and preselect the candidate when run <code>helm-semantic</code>. But Imenu is easier to extend without touching Semantic parser."},{"owner":{"reputation":156,"user_id":2084,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/ab1a56787ee3fc3602592a1909cbd0ea?s=128&d=identicon&r=PG&f=1","display_name":"Dipak C","link":"http://emacs.stackexchange.com/users/2084/dipak-c"},"reply_to_user":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414691174,"post_id":2860,"comment_id":3910,"body_markdown":"unfortunately, `helm-imenu` is also blank. in fact, both `helm-imenu` and `helm-semantic` are blank.","link":"http://emacs.stackexchange.com/questions/2860/how-to-force-evaluation-of-a-statement-in-my-init-file#comment3910_2860","body":"unfortunately, <code>helm-imenu</code> is also blank. in fact, both <code>helm-imenu</code> and <code>helm-semantic</code> are blank."},{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414691529,"post_id":2860,"comment_id":3911,"body_markdown":"You use `setq` which overrides the default `imenu-generic-expression`, and I think your regex is potentially wrong, so it shows nothing. Try removing your change and test `helm-imenu` again.","link":"http://emacs.stackexchange.com/questions/2860/how-to-force-evaluation-of-a-statement-in-my-init-file#comment3911_2860","body":"You use <code>setq</code> which overrides the default <code>imenu-generic-expression</code>, and I think your regex is potentially wrong, so it shows nothing. Try removing your change and test <code>helm-imenu</code> again."},{"owner":{"reputation":156,"user_id":2084,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/ab1a56787ee3fc3602592a1909cbd0ea?s=128&d=identicon&r=PG&f=1","display_name":"Dipak C","link":"http://emacs.stackexchange.com/users/2084/dipak-c"},"reply_to_user":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414702689,"post_id":2860,"comment_id":3918,"body_markdown":"@Tu Do: I've updated the methodology so that my new list of definitions is appended to the existing list (using the `,@` operator). As described in my (heavily) edited post above, the new code works but only after I manually evaluated part of the code (details above).","link":"http://emacs.stackexchange.com/questions/2860/how-to-force-evaluation-of-a-statement-in-my-init-file#comment3918_2860","body":"@Tu Do: I've updated the methodology so that my new list of definitions is appended to the existing list (using the <code>,@</code> operator). As described in my (heavily) edited post above, the new code works but only after I manually evaluated part of the code (details above)."},{"owner":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":0,"post_type":"question","creation_date":1414702847,"post_id":2860,"comment_id":3919,"body_markdown":"You're saying it doesn't take effect during initialization?","link":"http://emacs.stackexchange.com/questions/2860/how-to-force-evaluation-of-a-statement-in-my-init-file#comment3919_2860","body":"You're saying it doesn't take effect during initialization?"},{"owner":{"reputation":156,"user_id":2084,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/ab1a56787ee3fc3602592a1909cbd0ea?s=128&d=identicon&r=PG&f=1","display_name":"Dipak C","link":"http://emacs.stackexchange.com/users/2084/dipak-c"},"reply_to_user":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":0,"post_type":"question","creation_date":1414704904,"post_id":2860,"comment_id":3922,"body_markdown":"@Malabarba That's right, I've added before and after pictures for clarification.","link":"http://emacs.stackexchange.com/questions/2860/how-to-force-evaluation-of-a-statement-in-my-init-file#comment3922_2860","body":"@Malabarba That's right, I've added before and after pictures for clarification."}],"last_editor":{"reputation":156,"user_id":2084,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/ab1a56787ee3fc3602592a1909cbd0ea?s=128&d=identicon&r=PG&f=1","display_name":"Dipak C","link":"http://emacs.stackexchange.com/users/2084/dipak-c"},"comment_count":6,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":52,"favorite_count":0,"accepted_answer_id":2892,"answer_count":1,"score":0,"last_activity_date":1414736153,"creation_date":1414687221,"last_edit_date":1414720130,"question_id":2860,"body_markdown":"TL;DR: How can I force evaluation of a `setq` statement at start-up so that `imenu` updates appropriately? (You can skip down to the second code-block below, if you want.)\r\n\r\nI love the concept of `imenu` (esp. when integrated with `helm`) and I think it has great potential to improve my workflow...assuming I learn how to correctly set definitions for `imenu` categories. \r\n\r\nAs a simplified example, let's say that I'd like to add a few definitions to my `init` file's `imenu` which would be useful when making updates - namely, the list of imported packages.\r\n\r\nLet's consider the following three lines as the code we want to parse (purely illustrative; my `init` file doesn't actually have an explicit line for importing `dired` and `electric`):\r\n\r\n (defconst dc/default-directory "/path/to/directory")\r\n (use-package dired)\r\n (use-package electric)\r\n\r\nIn order to extract the constants and package names in `imenu`, I've included the code below in my `init.el` file. This code works BUT only after I manually `eval` the second line, (i.e., the second `setq` statement below).\r\n\r\n (setq dc-additions '(("Imported packages" ".*(use-package \\\\(.*\\\\))*" 1)\r\n \t\t ("Defined constants" ".*(defconst \\\\(.*\\\\))*" 1)))\r\n (setq imenu-generic-expression (copy-sequence `(,@dc-additions ,@imenu-generic-expression)))\r\n (add-hook 'emacs-lisp-mode 'imenu-generic-expression)\r\n\r\nIf I don't manually evaluate the second step, the `imenu` list shows only the default definitions. However, after I `eval` the second statement above, the `imenu` list correctly include includes items based on my definition.\r\n\r\nHow can I force evaluation of the second statement? In other words, what can I do to to ensure that `imenu` will automatically consider items based on my definition?\r\n***\r\nExhibit 1: `imenu` after start-up but before I manually `eval` the second `setq` statement:\r\n\r\n![enter image description here][1]\r\n\r\nExhibit 2: `imenu` after I manually `eval` the statement:\r\n\r\n![enter image description here][2]\r\n\r\n\r\n [1]: http://i.stack.imgur.com/Kv78R.png\r\n [2]: http://i.stack.imgur.com/iKKqe.png","link":"http://emacs.stackexchange.com/questions/2860/how-to-force-evaluation-of-a-statement-in-my-init-file","title":"How to force evaluation of a statement in my `init` file?","body":"<p>TL;DR: How can I force evaluation of a <code>setq</code> statement at start-up so that <code>imenu</code> updates appropriately? (You can skip down to the second code-block below, if you want.)</p>\n\n<p>I love the concept of <code>imenu</code> (esp. when integrated with <code>helm</code>) and I think it has great potential to improve my workflow...assuming I learn how to correctly set definitions for <code>imenu</code> categories. </p>\n\n<p>As a simplified example, let's say that I'd like to add a few definitions to my <code>init</code> file's <code>imenu</code> which would be useful when making updates - namely, the list of imported packages.</p>\n\n<p>Let's consider the following three lines as the code we want to parse (purely illustrative; my <code>init</code> file doesn't actually have an explicit line for importing <code>dired</code> and <code>electric</code>):</p>\n\n<pre><code>(defconst dc/default-directory \"/path/to/directory\")\n(use-package dired)\n(use-package electric)\n</code></pre>\n\n<p>In order to extract the constants and package names in <code>imenu</code>, I've included the code below in my <code>init.el</code> file. This code works BUT only after I manually <code>eval</code> the second line, (i.e., the second <code>setq</code> statement below).</p>\n\n<pre><code>(setq dc-additions '((\"Imported packages\" \".*(use-package \\\\(.*\\\\))*\" 1)\n (\"Defined constants\" \".*(defconst \\\\(.*\\\\))*\" 1)))\n(setq imenu-generic-expression (copy-sequence `(,@dc-additions ,@imenu-generic-expression)))\n(add-hook 'emacs-lisp-mode 'imenu-generic-expression)\n</code></pre>\n\n<p>If I don't manually evaluate the second step, the <code>imenu</code> list shows only the default definitions. However, after I <code>eval</code> the second statement above, the <code>imenu</code> list correctly include includes items based on my definition.</p>\n\n<p>How can I force evaluation of the second statement? In other words, what can I do to to ensure that <code>imenu</code> will automatically consider items based on my definition?</p>\n\n<hr>\n\n<p>Exhibit 1: <code>imenu</code> after start-up but before I manually <code>eval</code> the second <code>setq</code> statement:</p>\n\n<p><img src=\"http://i.stack.imgur.com/Kv78R.png\" alt=\"enter image description here\"></p>\n\n<p>Exhibit 2: <code>imenu</code> after I manually <code>eval</code> the statement:</p>\n\n<p><img src=\"http://i.stack.imgur.com/iKKqe.png\" alt=\"enter image description here\"></p>\n"},{"answers":[{"owner":{"reputation":425,"user_id":2223,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/8b728c7d6c1dce81f5a82249b7617756?s=128&d=identicon&r=PG&f=1","display_name":"jch","link":"http://emacs.stackexchange.com/users/2223/jch"},"last_editor":{"reputation":425,"user_id":2223,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/8b728c7d6c1dce81f5a82249b7617756?s=128&d=identicon&r=PG&f=1","display_name":"jch","link":"http://emacs.stackexchange.com/users/2223/jch"},"comment_count":0,"is_accepted":false,"score":3,"last_activity_date":1414715009,"last_edit_date":1414715009,"creation_date":1414705578,"answer_id":2873,"question_id":2871,"body_markdown":"Org files are just plain text files, so any technique that is able to synchronise plain text files will work fine with org files.\r\n\r\nMy favourite synchronisation tool is <a href="http://www.cis.upenn.edu/~bcpierce/unison/">Unison</a>. With the right configuration file, I type\r\n\r\n unison org\r\n\r\nand Unison will compare files in my `~/org/` directories on both my machines, let me interactively review its actions, then copy the files that need to be copied and invoke an external merge tool for the files that need merging.","link":"http://emacs.stackexchange.com/questions/2871/keeping-my-org-files-in-sync-across-multiple-computers/2873#2873","title":"Keeping my .org files in sync across multiple computers","body":"<p>Org files are just plain text files, so any technique that is able to synchronise plain text files will work fine with org files.</p>\n\n<p>My favourite synchronisation tool is <a href=\"http://www.cis.upenn.edu/~bcpierce/unison/\" rel=\"nofollow\">Unison</a>. With the right configuration file, I type</p>\n\n<pre><code>unison org\n</code></pre>\n\n<p>and Unison will compare files in my <code>~/org/</code> directories on both my machines, let me interactively review its actions, then copy the files that need to be copied and invoke an external merge tool for the files that need merging.</p>\n"},{"owner":{"reputation":255,"user_id":35,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/18b80f3021a241d9b85c236dafbcd64b?s=128&d=identicon&r=PG","display_name":"Ryan","link":"http://emacs.stackexchange.com/users/35/ryan"},"comment_count":0,"is_accepted":false,"score":2,"last_activity_date":1414706455,"creation_date":1414706455,"answer_id":2874,"question_id":2871,"body_markdown":"Org mode does not provide any syncing functionality itself. You would have to rely on a separate application like Dropbox to sync your files. Dropbox syncs not just often, but immediately when files change, so unless you change a file and immediately shut off your computer, you will keep your files in sync.","link":"http://emacs.stackexchange.com/questions/2871/keeping-my-org-files-in-sync-across-multiple-computers/2874#2874","title":"Keeping my .org files in sync across multiple computers","body":"<p>Org mode does not provide any syncing functionality itself. You would have to rely on a separate application like Dropbox to sync your files. Dropbox syncs not just often, but immediately when files change, so unless you change a file and immediately shut off your computer, you will keep your files in sync.</p>\n"},{"owner":{"reputation":51,"user_id":2317,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6b2434a658adfce8c1fea450d6f48773?s=128&d=identicon&r=PG&f=1","display_name":"Alain","link":"http://emacs.stackexchange.com/users/2317/alain"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414707814,"creation_date":1414707814,"answer_id":2876,"question_id":2871,"body_markdown":"Dropbox (or any other cloud storage I guess) is the way to go. In addition, this is really handy to synchronize the Emacs setup in `~/.emacs.d` (use `mklink` on Windows).","link":"http://emacs.stackexchange.com/questions/2871/keeping-my-org-files-in-sync-across-multiple-computers/2876#2876","title":"Keeping my .org files in sync across multiple computers","body":"<p>Dropbox (or any other cloud storage I guess) is the way to go. In addition, this is really handy to synchronize the Emacs setup in <code>~/.emacs.d</code> (use <code>mklink</code> on Windows).</p>\n"},{"owner":{"reputation":360,"user_id":290,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/4569aec00cb223b3fbf484f9e7ba1256?s=128&d=identicon&r=PG","display_name":"Renan Ranelli","link":"http://emacs.stackexchange.com/users/290/renan-ranelli"},"comment_count":0,"is_accepted":false,"score":2,"last_activity_date":1414715968,"creation_date":1414715968,"answer_id":2882,"question_id":2871,"body_markdown":"I personally have this problem and have been using [copy](www.copy.com) instead of Dropbox to have my files in sync. (I don't use Dropbox because of privacy issues). Just like Dropbox, Copy offers clients for all the major platforms.\r\n\r\nSometimes I forget to save my org buffers, so I have hacked the following functions to save all org files whenever I save some file. Not a great solution, but it serves my purpose.\r\n\r\n (add-hook 'after-save-hook 'org-save-all-org-buffers)\r\n\r\nAlso, if you hold sensitive data in your org files, I recommend you to take a look at [this page](http://orgmode.org/worg/org-tutorials/encrypting-files.html). I use org-crypt which is amazing.","link":"http://emacs.stackexchange.com/questions/2871/keeping-my-org-files-in-sync-across-multiple-computers/2882#2882","title":"Keeping my .org files in sync across multiple computers","body":"<p>I personally have this problem and have been using copy instead of Dropbox to have my files in sync. (I don't use Dropbox because of privacy issues). Just like Dropbox, Copy offers clients for all the major platforms.</p>\n\n<p>Sometimes I forget to save my org buffers, so I have hacked the following functions to save all org files whenever I save some file. Not a great solution, but it serves my purpose.</p>\n\n<pre><code>(add-hook 'after-save-hook 'org-save-all-org-buffers)\n</code></pre>\n\n<p>Also, if you hold sensitive data in your org files, I recommend you to take a look at <a href=\"http://orgmode.org/worg/org-tutorials/encrypting-files.html\" rel=\"nofollow\">this page</a>. I use org-crypt which is amazing.</p>\n"},{"owner":{"reputation":41,"user_id":2344,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a17d0aed8c29ac52d5693ff864adba74?s=128&d=identicon&r=PG","display_name":"razcampagne","link":"http://emacs.stackexchange.com/users/2344/razcampagne"},"comment_count":0,"is_accepted":false,"score":4,"last_activity_date":1414723518,"creation_date":1414723518,"answer_id":2886,"question_id":2871,"body_markdown":"I use git-annex assistant to sync my org files across my computers and even my phone (a jolla so the linux binary works out of the box but there is also an android version).\r\n\r\nIt works like dropbox in that whenever you save a file it will try to sync it but it is decentralized and free (as in free speech and free beer).\r\n\r\nThe setup is straightforward if you know git but you need some time to familiarize yourself with all the options.\r\n\r\nYou can find more at http://git-annex.branchable.com","link":"http://emacs.stackexchange.com/questions/2871/keeping-my-org-files-in-sync-across-multiple-computers/2886#2886","title":"Keeping my .org files in sync across multiple computers","body":"<p>I use git-annex assistant to sync my org files across my computers and even my phone (a jolla so the linux binary works out of the box but there is also an android version).</p>\n\n<p>It works like dropbox in that whenever you save a file it will try to sync it but it is decentralized and free (as in free speech and free beer).</p>\n\n<p>The setup is straightforward if you know git but you need some time to familiarize yourself with all the options.</p>\n\n<p>You can find more at <a href=\"http://git-annex.branchable.com\" rel=\"nofollow\">http://git-annex.branchable.com</a></p>\n"}],"tags":["org-mode"],"owner":{"reputation":136,"user_id":2042,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/233098e41e5f22e4cdf7ecea04ffb991?s=128&d=identicon&r=PG","display_name":"Zavior","link":"http://emacs.stackexchange.com/users/2042/zavior"},"comments":[{"owner":{"reputation":1217,"user_id":45,"user_type":"registered","accept_rate":93,"profile_image":"https://www.gravatar.com/avatar/073274c272b84eed27790fc3e5231d46?s=128&d=identicon&r=PG&f=1","display_name":"King Shimkus","link":"http://emacs.stackexchange.com/users/45/king-shimkus"},"edited":false,"score":1,"post_type":"question","creation_date":1414705534,"post_id":2871,"comment_id":3923,"body_markdown":"Does this help? [Putting your org...](http://orgmode.org/worg/org-tutorials/org-vcs.html)","link":"http://emacs.stackexchange.com/questions/2871/keeping-my-org-files-in-sync-across-multiple-computers#comment3923_2871","body":"Does this help? <a href=\"http://orgmode.org/worg/org-tutorials/org-vcs.html\" rel=\"nofollow\">Putting your org...</a>"},{"owner":{"reputation":512,"user_id":2264,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/9261936847b5a31e15da6e86533d3de3?s=128&d=identicon&r=PG","display_name":"Sean Allred","link":"http://emacs.stackexchange.com/users/2264/sean-allred"},"edited":false,"score":0,"post_type":"question","creation_date":1414706465,"post_id":2871,"comment_id":3925,"body_markdown":"Dropbox syncs files as soon as they are written. Internally, I believe Dropbox uses a Python script to monitor the directory.","link":"http://emacs.stackexchange.com/questions/2871/keeping-my-org-files-in-sync-across-multiple-computers#comment3925_2871","body":"Dropbox syncs files as soon as they are written. Internally, I believe Dropbox uses a Python script to monitor the directory."},{"owner":{"reputation":101,"user_id":2224,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b4968ea2e03e3781500351ae376316c4?s=128&d=identicon&r=PG","display_name":"jon","link":"http://emacs.stackexchange.com/users/2224/jon"},"edited":false,"score":0,"post_type":"question","creation_date":1414713689,"post_id":2871,"comment_id":3932,"body_markdown":"If security/privacy is an issue, [SpiderOak](https://spideroak.com/) is also pretty great.","link":"http://emacs.stackexchange.com/questions/2871/keeping-my-org-files-in-sync-across-multiple-computers#comment3932_2871","body":"If security/privacy is an issue, <a href=\"https://spideroak.com/\" rel=\"nofollow\">SpiderOak</a> is also pretty great."}],"comment_count":3,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":258,"favorite_count":0,"answer_count":5,"score":7,"last_activity_date":1414723518,"creation_date":1414704876,"question_id":2871,"body_markdown":"How can I keep my .org files up to date across several computers, perhaps across multiple platforms(linux/windows)?\r\n\r\nI could keep all the .org files in git for example, but that would require me to remember to pull and push to keep the repo updated. Could work with a few scripts to automatically handle the files, as I don't have that many.\r\n\r\nI could try using dropbox for this as well. I'd assume dropbox syncs the files often enough to not cause problems.\r\n\r\nDoes org-mode offer any functionality to help with synchronizing the files across multiple locations?","link":"http://emacs.stackexchange.com/questions/2871/keeping-my-org-files-in-sync-across-multiple-computers","title":"Keeping my .org files in sync across multiple computers","body":"<p>How can I keep my .org files up to date across several computers, perhaps across multiple platforms(linux/windows)?</p>\n\n<p>I could keep all the .org files in git for example, but that would require me to remember to pull and push to keep the repo updated. Could work with a few scripts to automatically handle the files, as I don't have that many.</p>\n\n<p>I could try using dropbox for this as well. I'd assume dropbox syncs the files often enough to not cause problems.</p>\n\n<p>Does org-mode offer any functionality to help with synchronizing the files across multiple locations?</p>\n"},{"answers":[{"owner":{"reputation":1,"user_id":804,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ca8e672ae4fd9972d188f31ca2c41775?s=128&d=identicon&r=PG","display_name":"sk8ingdom","link":"http://emacs.stackexchange.com/users/804/sk8ingdom"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414710004,"creation_date":1414710004,"answer_id":2877,"question_id":2869,"body_markdown":"I've sort of tangentially looked at this issue. Take a look at the [org-protocol.el][1]. It's bundled with org-mode. Specifically, the org-protocol-do-capture function converts a list, "parts" (which you seem to already have), to org-mode properties using org-store-link-props function and then calls org-capture. This assumes that you have a capture template with placeholders such as %:link. You can define the properties to be whatever you like.\r\n\r\nI've done [something similar][2] to scrape title, author, date, source, etc. from site APIs. If you end up looking at this code, be sure to also look at capture-templates.el.\r\n\r\n [1]: http://orgmode.org/worg/org-contrib/org-protocol.html\r\n [2]: https://github.com/sk8ingdom/.emacs.d/blob/master/org-mode-config/org-protocol-templates.el\r\n\r\nIf you're working with JSON data, the json.el and / or request.el might be useful.","link":"http://emacs.stackexchange.com/questions/2869/turn-a-list-or-data-structure-into-an-org-document/2877#2877","title":"Turn a list or data structure into an org document","body":"<p>I've sort of tangentially looked at this issue. Take a look at the <a href=\"http://orgmode.org/worg/org-contrib/org-protocol.html\" rel=\"nofollow\">org-protocol.el</a>. It's bundled with org-mode. Specifically, the org-protocol-do-capture function converts a list, \"parts\" (which you seem to already have), to org-mode properties using org-store-link-props function and then calls org-capture. This assumes that you have a capture template with placeholders such as %:link. You can define the properties to be whatever you like.</p>\n\n<p>I've done <a href=\"https://github.com/sk8ingdom/.emacs.d/blob/master/org-mode-config/org-protocol-templates.el\" rel=\"nofollow\">something similar</a> to scrape title, author, date, source, etc. from site APIs. If you end up looking at this code, be sure to also look at capture-templates.el.</p>\n\n<p>If you're working with JSON data, the json.el and / or request.el might be useful.</p>\n"},{"owner":{"reputation":486,"user_id":1974,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/bd580f3842d43ba9dd42aff4914a38d3?s=128&d=identicon&r=PG&f=1","display_name":"rasmus","link":"http://emacs.stackexchange.com/users/1974/rasmus"},"comments":[{"owner":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"edited":false,"score":0,"post_type":"answer","creation_date":1414779800,"post_id":2885,"comment_id":4006,"body_markdown":"Perfect! Thanks a lot.","link":"http://emacs.stackexchange.com/questions/2869/turn-a-list-or-data-structure-into-an-org-document/2885#comment4006_2885","body":"Perfect! Thanks a lot."}],"last_editor":{"reputation":486,"user_id":1974,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/bd580f3842d43ba9dd42aff4914a38d3?s=128&d=identicon&r=PG&f=1","display_name":"rasmus","link":"http://emacs.stackexchange.com/users/1974/rasmus"},"comment_count":1,"is_accepted":true,"score":4,"last_activity_date":1414722781,"last_edit_date":1414722781,"creation_date":1414721912,"answer_id":2885,"question_id":2869,"body_markdown":"This is the job of [`org-element`][1], the *awesome*(!) work of **Nicolas Goaziou**. If you don't know `org-element` and you care about org-development this is something you should look into. It is not only a great tool to work with, it is also increasingly powering `org`. Most notably the `org-export` ([`ox`][2]), but also functions in e.g. `org.el`.\r\n\r\nTo get the "lisp representation" of an element under point use `org-element-at-point` or `org-element-context`. To get the representation of the buffer use `org-element-parse-buffer`. While not directly relevant here, be aware of `org-element-map`.\r\n\r\nTo go from the "lisp representation" of an `element`, `secondary string` or `parse tree` back to the ["Org syntax representation"][3] use `org-element-interpret-data`. This is *the* (only) way to turn a "lisp representation" into a "Org syntax representation". You will probably not want to write this representation manually, though. Here's is a pretty small representation of your first headline\r\n\r\n (org-element-interpret-data\r\n '(headline (:title "One headline" :level 1)\r\n (property-drawer nil ((node-property (:key "property1" :value "value1"))\r\n (node-property (:key "property2" :value "value2"))))\r\n (#("Some much longer content."))))\r\n\r\nIf you must add both headlines add a `parse tree`\r\n\r\n (org-element-interpret-data\r\n '(org-data nil (headline (:title "One headline" :level 1)\r\n (property-drawer nil ((node-property (:key "property1" :value "value1"))\r\n (node-property (:key "property2" :value "value2"))))\r\n (#("Some much longer content.")))\r\n (headline (:title "Second headline" :level 1)\r\n (property-drawer nil ((node-property (:key "property1" :value "value1"))\r\n (node-property (:key "property2" :value "value2"))))\r\n (#("More much longer content.")))))\r\n\r\n\r\nYou may find that **Thorsten Jolitz**'s [`org-dp`](https://github.com/tj64/org-dp) library will aid you such efforts. My understanding (I haven't used `org-dp`) is that `org-dp` is a meant to make it easer for to use "lisp representation" to create new "Org syntax representation" (as this it not a goal of `org-element` per se).\r\n\r\nFor further clarification [`gmane.emacs.orgmode`][4] is really the appropriate forum.\r\n\r\n\r\n [1]: http://orgmode.org/worg/dev/org-element-api.html\r\n [2]: http://orgmode.org/org.html#Exporting\r\n [3]: http://orgmode.org/worg/dev/org-syntax.html\r\n [4]: http://dir.gmane.org/gmane.emacs.orgmode","link":"http://emacs.stackexchange.com/questions/2869/turn-a-list-or-data-structure-into-an-org-document/2885#2885","title":"Turn a list or data structure into an org document","body":"<p>This is the job of <a href=\"http://orgmode.org/worg/dev/org-element-api.html\" rel=\"nofollow\"><code>org-element</code></a>, the <em>awesome</em>(!) work of <strong>Nicolas Goaziou</strong>. If you don't know <code>org-element</code> and you care about org-development this is something you should look into. It is not only a great tool to work with, it is also increasingly powering <code>org</code>. Most notably the <code>org-export</code> (<a href=\"http://orgmode.org/org.html#Exporting\" rel=\"nofollow\"><code>ox</code></a>), but also functions in e.g. <code>org.el</code>.</p>\n\n<p>To get the \"lisp representation\" of an element under point use <code>org-element-at-point</code> or <code>org-element-context</code>. To get the representation of the buffer use <code>org-element-parse-buffer</code>. While not directly relevant here, be aware of <code>org-element-map</code>.</p>\n\n<p>To go from the \"lisp representation\" of an <code>element</code>, <code>secondary string</code> or <code>parse tree</code> back to the <a href=\"http://orgmode.org/worg/dev/org-syntax.html\" rel=\"nofollow\">\"Org syntax representation\"</a> use <code>org-element-interpret-data</code>. This is <em>the</em> (only) way to turn a \"lisp representation\" into a \"Org syntax representation\". You will probably not want to write this representation manually, though. Here's is a pretty small representation of your first headline</p>\n\n<pre><code>(org-element-interpret-data\n '(headline (:title \"One headline\" :level 1)\n (property-drawer nil ((node-property (:key \"property1\" :value \"value1\"))\n (node-property (:key \"property2\" :value \"value2\"))))\n (#(\"Some much longer content.\"))))\n</code></pre>\n\n<p>If you must add both headlines add a <code>parse tree</code></p>\n\n<pre><code>(org-element-interpret-data\n '(org-data nil (headline (:title \"One headline\" :level 1)\n (property-drawer nil ((node-property (:key \"property1\" :value \"value1\"))\n (node-property (:key \"property2\" :value \"value2\"))))\n (#(\"Some much longer content.\")))\n (headline (:title \"Second headline\" :level 1)\n (property-drawer nil ((node-property (:key \"property1\" :value \"value1\"))\n (node-property (:key \"property2\" :value \"value2\"))))\n (#(\"More much longer content.\")))))\n</code></pre>\n\n<p>You may find that <strong>Thorsten Jolitz</strong>'s <a href=\"https://github.com/tj64/org-dp\" rel=\"nofollow\"><code>org-dp</code></a> library will aid you such efforts. My understanding (I haven't used <code>org-dp</code>) is that <code>org-dp</code> is a meant to make it easer for to use \"lisp representation\" to create new \"Org syntax representation\" (as this it not a goal of <code>org-element</code> per se).</p>\n\n<p>For further clarification <a href=\"http://dir.gmane.org/gmane.emacs.orgmode\" rel=\"nofollow\"><code>gmane.emacs.orgmode</code></a> is really the appropriate forum.</p>\n"}],"tags":["org-mode"],"owner":{"reputation":3999,"user_id":50,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/c14505947446e90f2a14fd8f3dd3cf94?s=128&d=identicon&r=PG","display_name":"Malabarba","link":"http://emacs.stackexchange.com/users/50/malabarba"},"comments":[{"owner":{"reputation":512,"user_id":2264,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/9261936847b5a31e15da6e86533d3de3?s=128&d=identicon&r=PG","display_name":"Sean Allred","link":"http://emacs.stackexchange.com/users/2264/sean-allred"},"edited":false,"score":0,"post_type":"question","creation_date":1414706659,"post_id":2869,"comment_id":3926,"body_markdown":"Oh my, this would be very useful. +1. I would note that even Org does so manually. See `org-insert-drawer`. (That is, I would imagine if such a converter existed, this function would call that one with `nil`.)","link":"http://emacs.stackexchange.com/questions/2869/turn-a-list-or-data-structure-into-an-org-document#comment3926_2869","body":"Oh my, this would be very useful. +1. I would note that even Org does so manually. See <code>org-insert-drawer</code>. (That is, I would imagine if such a converter existed, this function would call that one with <code>nil</code>.)"}],"comment_count":1,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":true,"view_count":50,"favorite_count":0,"accepted_answer_id":2885,"answer_count":2,"score":3,"last_activity_date":1414722781,"creation_date":1414703482,"question_id":2869,"body_markdown":"I'm writting a package which dowloads a list of healines, contents,\r\nand some other properties, which are to be displayed to the user. For\r\nthe moment, an `org-mode` buffer seems like a good way of displaying\r\nthese headlines.\r\n\r\nBelow is an example of how this list might be structured. It is merely\r\nillustrative, I can easily convert it to any other structure as\r\nnecessary.\r\n\r\n '(("One headline" "Some much longer content."\r\n (property1 . value)\r\n (property2 . value))\r\n ("Second headline" "More much longer content."\r\n (property1 . value)\r\n (property2 . value)))\r\n\r\n**Is there a function or package which prints such a list into an `org-mode` buffer?**\r\n\r\nHere's the desired output.\r\n\r\n * One headline\r\n :PROPERTIES:\r\n :property1: value\r\n :property2: value\r\n :END:\r\n Some much longer content.\r\n \r\n * Second headline\r\n :PROPERTIES:\r\n :property1: value\r\n :property2: value\r\n :END:\r\n More much longer content.\r\n\r\nI could do this manually, I'm just wondering if there might be\r\nsomething out there.\r\n","link":"http://emacs.stackexchange.com/questions/2869/turn-a-list-or-data-structure-into-an-org-document","title":"Turn a list or data structure into an org document","body":"<p>I'm writting a package which dowloads a list of healines, contents,\nand some other properties, which are to be displayed to the user. For\nthe moment, an <code>org-mode</code> buffer seems like a good way of displaying\nthese headlines.</p>\n\n<p>Below is an example of how this list might be structured. It is merely\nillustrative, I can easily convert it to any other structure as\nnecessary.</p>\n\n<pre><code>'((\"One headline\" \"Some much longer content.\"\n (property1 . value)\n (property2 . value))\n (\"Second headline\" \"More much longer content.\"\n (property1 . value)\n (property2 . value)))\n</code></pre>\n\n<p><strong>Is there a function or package which prints such a list into an <code>org-mode</code> buffer?</strong></p>\n\n<p>Here's the desired output.</p>\n\n<pre><code>* One headline\n :PROPERTIES:\n :property1: value\n :property2: value\n :END:\nSome much longer content.\n\n* Second headline\n :PROPERTIES:\n :property1: value\n :property2: value\n :END:\nMore much longer content.\n</code></pre>\n\n<p>I could do this manually, I'm just wondering if there might be\nsomething out there.</p>\n"}],"has_more":true,"quota_max":300,"quota_remaining":224} diff --git a/sample-question-unauthenticated.el b/sample-question-unauthenticated.el index 0e1c8c3..b448b73 100644 --- a/sample-question-unauthenticated.el +++ b/sample-question-unauthenticated.el @@ -1,45 +1,34 @@ - (defvar sample-question-unauthenticated + (json-read-file "sample-question-unauthenticated.json")) +(defvar sample-frontpage + (json-read-file "sample-frontpage.json")) + ;;; A sample of data offered by the question object, without authentication. - '((body . "<p>I am getting \"rgb(18, 115, 224)\" from a dom element. Now I want to assign the color(whatever i am getting from this element) to a span element. So I need hexadecimal equivalent of the color I am getting. For this I can use </p> +;; (pp sample-question-unauthenticated (current-buffer)) -<pre><code>\"#\" + componentToHex(r) + componentToHex(g) + componentToHex(b) -</code></pre> +(defun sample-question-markdown () + "Renders the question list usiong markdown for the content. +Doesn't seem like markdown gets fontified. Which is disapointing. :-(" + (interactive) + (find-file "sample.org") + (setf (buffer-string) + (org-element-interpret-data + (stack-lto--question sample-question-unauthenticated)))) -<p>but, My question here's how can I get the r, g,b component values from \"rgb(18, 115, 224)\"</p> -") - (title . "get r, g, b component of a color in rgb() format") - (link . "http://stackoverflow.com/questions/26679366/get-r-g-b-component-of-a-color-in-rgb-format") - (body_markdown . "I am getting "rgb(18, 115, 224)" from a dom element. Now I want to assign the color(whatever i am getting from this element) to a span element. So I need hexadecimal equivalent of the color I am getting. For this I can use
-
- "#" + componentToHex(r) + componentToHex(g) + componentToHex(b)
-but, My question here's how can I get the r, g,b component values from "rgb(18, 115, 224)"") - (question_id . 26679366) - (creation_date . 1414773223.0) - (last_activity_date . 1414773433.0) - (score . 0) - (answer_count . 2) - (view_count . 16) - (is_answered . :json-false) - (comment_count . 1) - (comments . [((comment_id . 41957708) (post_id . 26679366) (creation_date . 1414773413.0) (score . 0) (edited . :json-false) (owner (link . "http://stackoverflow.com/users/14104/epascarello") (display_name . "epascarello") (profile_image . "https://www.gravatar.com/avatar/760b4da77fd54d37c104029ff1f56749?s=128&d=identicon&r=PG") (user_type . "registered") (user_id . 14104) (reputation . 76145)))]) - (owner (link . "http://stackoverflow.com/users/3867678/rasmita-dash") (display_name . "Rasmita Dash") (profile_image . "http://graph.facebook.com/100001985977413/picture?type=large") (accept_rate . 45) (user_type . "registered") (user_id . 3867678) (reputation . 90)) - (tags . ["javascript" "jquery" "html" "css" "colors"]) - (answers . [((body . "<blockquote> - <p>Now I want to assign the color(whatever i am getting from this element) to a span element.</p> -</blockquote> +(defun sample-frontpage-markdown () + "Renders the question list usiong markdown for the content. +Doesn't seem like markdown gets fontified. Which is disapointing. :-(" + (interactive) + (find-file "sample.org") + (erase-buffer) + (mapcar + (lambda (x) + (insert + (org-element-interpret-data + (stack-lto--question x)))) + (cdr (assoc 'items sample-frontpage))) + (org-global-cycle 1)) -<p>No you don't, you can just use <code>rgb(18, 115, 224)</code> directly for a color value in CSS.</p> -") (link . "http://stackoverflow.com/questions/26679366/get-r-g-b-component-of-a-color-in-rgb-format/26679414#26679414") (body_markdown . "> Now I want to assign the color(whatever i am getting from this element) to a span element.
-
-No you don't, you can just use `rgb(18, 115, 224)` directly for a color value in CSS.") (question_id . 26679366) (answer_id . 26679414) (creation_date . 1414773411.0) (last_activity_date . 1414773411.0) (score . 0) (is_accepted . :json-false) (comment_count . 0) (owner (link . "http://stackoverflow.com/users/157247/t-j-crowder") (display_name . "T.J. Crowder") (profile_image . "https://www.gravatar.com/avatar/ca3e484c121268e4c8302616b2395eb9?s=128&d=identicon&r=PG") (accept_rate . 90) (user_type . "registered") (user_id . 157247) (reputation . 307244))) ((body . "<p>You don't need to convert it to anything. If you want to assign this value to a span colour, then simply do:</p> +(provide 'sample-question-unauthenticated) -<pre><code>var clr = rgb(18, 115, 224); -$('#myspan').css('color', clr); -</code></pre> -") (link . "http://stackoverflow.com/questions/26679366/get-r-g-b-component-of-a-color-in-rgb-format/26679423#26679423") (body_markdown . "You don't need to convert it to anything. If you want to assign this value to a span colour, then simply do:
-
- var clr = rgb(18, 115, 224);
- $('#myspan').css('color', clr);") (question_id . 26679366) (answer_id . 26679423) (creation_date . 1414773433.0) (last_activity_date . 1414773433.0) (score . 0) (is_accepted . :json-false) (comment_count . 0) (owner (link . "http://stackoverflow.com/users/717214/aleks-g") (display_name . "Aleks G") (profile_image . "https://www.gravatar.com/avatar/9075315c5f4b734a8f2567be54a4cc45?s=128&d=identicon&r=PG") (accept_rate . 92) (user_type . "registered") (user_id . 717214) (reputation . 26812)))]))) -(provide 'sample-question-unauthenticated) diff --git a/sample-question-unauthenticated.json b/sample-question-unauthenticated.json new file mode 100644 index 0000000..732003d --- /dev/null +++ b/sample-question-unauthenticated.json @@ -0,0 +1 @@ +{"answers":[{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414793088,"creation_date":1414793088,"answer_id":2936,"question_id":2919,"body_markdown":"For your use case, there's still hope though. Since you use `etags`, it can be used with `helm-etags-select`, the Helm built-in command. To use it, simply follow theses steps:\r\n\r\n- First, run the command to generate TAGS file.\r\n- Second, use `find-tag` to feed it to Emacs; if the TAGS file is too large and Emacs asks you to confirm, just accept it. Your whole TAGS file will be loaded in Emacs and there's no more reloading.\r\n- Finally, just execute `helm-etags-select` on any symbol on your Emacs. If there exists only one definition in your project, jump instantly; otherwise, display a Helm buffer for you to choose from.","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable/2936#2936","title":""Making tag completion table" Freezes/Blocks -- how to disable","body":"<p>For your use case, there's still hope though. Since you use <code>etags</code>, it can be used with <code>helm-etags-select</code>, the Helm built-in command. To use it, simply follow theses steps:</p>\n\n<ul>\n<li>First, run the command to generate TAGS file.</li>\n<li>Second, use <code>find-tag</code> to feed it to Emacs; if the TAGS file is too large and Emacs asks you to confirm, just accept it. Your whole TAGS file will be loaded in Emacs and there's no more reloading.</li>\n<li>Finally, just execute <code>helm-etags-select</code> on any symbol on your Emacs. If there exists only one definition in your project, jump instantly; otherwise, display a Helm buffer for you to choose from.</li>\n</ul>\n"}],"tags":["autocomplete","performance","ctags"],"owner":{"reputation":11,"user_id":2265,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a2e453f8f1cfc1ff0d7428c3b66ddc9a?s=128&d=identicon&r=PG","display_name":"cheezy","link":"http://emacs.stackexchange.com/users/2265/cheezy"},"comments":[{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414770948,"post_id":2919,"comment_id":3992,"body_markdown":"For jumping to definition/references, you can use GNU Global with ggtags/helm-gtags. Guarantee to work on large project like Linux kernel without any delay. You may want to look at my [C/C++ guide](http://tuhdo.github.io/c-ide.html). I covered code navigation (jump to definition/references), code completion, compiling and debugging support. I already created a demo configuration for playing with, so you only need to walk through the features without configuring anything.","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment3992_2919","body":"For jumping to definition/references, you can use GNU Global with ggtags/helm-gtags. Guarantee to work on large project like Linux kernel without any delay. You may want to look at my <a href=\"http://tuhdo.github.io/c-ide.html\" rel=\"nofollow\">C/C++ guide</a>. I covered code navigation (jump to definition/references), code completion, compiling and debugging support. I already created a demo configuration for playing with, so you only need to walk through the features without configuring anything."},{"owner":{"reputation":11,"user_id":2265,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a2e453f8f1cfc1ff0d7428c3b66ddc9a?s=128&d=identicon&r=PG","display_name":"cheezy","link":"http://emacs.stackexchange.com/users/2265/cheezy"},"reply_to_user":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414772414,"post_id":2919,"comment_id":3993,"body_markdown":"Your guides were the ones that got me started with emacs (especially w/ C++)! Our build system is very complicated and `#include "..."` can live in various places that are not known until build time. So, ggtags wouldn't be able to generate tags for many of the files. Currently, our build tools allow us to `make etags` to generate emacs compatible tags, but there is no `make ggtags` equivalent. So, I'm stuck with etags for now. Any ideas?","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment3993_2919","body":"Your guides were the ones that got me started with emacs (especially w/ C++)! Our build system is very complicated and <code>#include "..."</code> can live in various places that are not known until build time. So, ggtags wouldn't be able to generate tags for many of the files. Currently, our build tools allow us to <code>make etags</code> to generate emacs compatible tags, but there is no <code>make ggtags</code> equivalent. So, I'm stuck with etags for now. Any ideas?"},{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414773753,"post_id":2919,"comment_id":3995,"body_markdown":"Hmm I see. The situation is more complicated now. You mentioned `ggtags` cannot generate tags, but did you use plain `gtags` on the command line at project root? You should try this and invoke ggtags again. There should not be `make ggtags` because the real command is `gtags`; `ggtags` is just a package name of Emacs that use it. Another option is that you can use [ctags](http://ctags.sourceforge.net/); `ggtags` can also recognize `ctags` tags and it's also fast. You can generate ctags tags when invoking `ggtags-create-tags` and it asks for using `ctags` client.","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment3995_2919","body":"Hmm I see. The situation is more complicated now. You mentioned <code>ggtags</code> cannot generate tags, but did you use plain <code>gtags</code> on the command line at project root? You should try this and invoke ggtags again. There should not be <code>make ggtags</code> because the real command is <code>gtags</code>; <code>ggtags</code> is just a package name of Emacs that use it. Another option is that you can use <a href=\"http://ctags.sourceforge.net/\" rel=\"nofollow\">ctags</a>; <code>ggtags</code> can also recognize <code>ctags</code> tags and it's also fast. You can generate ctags tags when invoking <code>ggtags-create-tags</code> and it asks for using <code>ctags</code> client."},{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414774141,"post_id":2919,"comment_id":3996,"body_markdown":"Anyway, if `gtags` could not know about such details, I don't think the built-in `etags` (comes with Emacs), or `ctags` (I linked above) would be able to do it. I think you only use `ggtags` to create tags at current directory, not project root. Run the command `gtags` at project root, or when `ggtags` asks for where to generate, navigate to project root and you will be fine.","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment3996_2919","body":"Anyway, if <code>gtags</code> could not know about such details, I don't think the built-in <code>etags</code> (comes with Emacs), or <code>ctags</code> (I linked above) would be able to do it. I think you only use <code>ggtags</code> to create tags at current directory, not project root. Run the command <code>gtags</code> at project root, or when <code>ggtags</code> asks for where to generate, navigate to project root and you will be fine."},{"owner":{"reputation":11,"user_id":2265,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a2e453f8f1cfc1ff0d7428c3b66ddc9a?s=128&d=identicon&r=PG","display_name":"cheezy","link":"http://emacs.stackexchange.com/users/2265/cheezy"},"reply_to_user":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414777453,"post_id":2919,"comment_id":4001,"body_markdown":"I verified your statement (all the tag programs can only generate from project root down the tree). `make etags` works because it calls etags once it evaluates where all the `.h` files live.","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment4001_2919","body":"I verified your statement (all the tag programs can only generate from project root down the tree). <code>make etags</code> works because it calls etags once it evaluates where all the <code>.h</code> files live."},{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414777545,"post_id":2919,"comment_id":4002,"body_markdown":"So, it did work? If so, may I turn my comment into answer?","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment4002_2919","body":"So, it did work? If so, may I turn my comment into answer?"},{"owner":{"reputation":11,"user_id":2265,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a2e453f8f1cfc1ff0d7428c3b66ddc9a?s=128&d=identicon&r=PG","display_name":"cheezy","link":"http://emacs.stackexchange.com/users/2265/cheezy"},"reply_to_user":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414778081,"post_id":2919,"comment_id":4003,"body_markdown":"So, if I'm stuck with etags for completeness, do you have any suggestions for 1) Loading the tag file asynchronously 2) Disable autoreload of the tags file?","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment4003_2919","body":"So, if I'm stuck with etags for completeness, do you have any suggestions for 1) Loading the tag file asynchronously 2) Disable autoreload of the tags file?"},{"owner":{"reputation":11,"user_id":2265,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a2e453f8f1cfc1ff0d7428c3b66ddc9a?s=128&d=identicon&r=PG","display_name":"cheezy","link":"http://emacs.stackexchange.com/users/2265/cheezy"},"reply_to_user":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414778190,"post_id":2919,"comment_id":4004,"body_markdown":"Sorry I wasn't very clear. Without involving the `make` command, any tag generation is incomplete. You can turn your comment into an answer, and I can accept it in a day or two to give others a chance to answer","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment4004_2919","body":"Sorry I wasn't very clear. Without involving the <code>make</code> command, any tag generation is incomplete. You can turn your comment into an answer, and I can accept it in a day or two to give others a chance to answer"},{"owner":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414779434,"post_id":2919,"comment_id":4005,"body_markdown":"There's one possibility, not sure if you try: since you already have you TAGS file at project root (generated by `etags`), `ggtags` will use that file instead of GTAGS. Did you move the TAGS file (generated by `etags`) elsewhere? Personally, I use `helm-gtags` + GTAGS and always jump instantly, even in the Linux kernel that `etags` generates almost 1 GB. You mention that only some ".h" files available at build time, do you mean those files only generated after the build? Even if it is the case, it's hard to think that any tag program misses those if search recursively.","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment4005_2919","body":"There's one possibility, not sure if you try: since you already have you TAGS file at project root (generated by <code>etags</code>), <code>ggtags</code> will use that file instead of GTAGS. Did you move the TAGS file (generated by <code>etags</code>) elsewhere? Personally, I use <code>helm-gtags</code> + GTAGS and always jump instantly, even in the Linux kernel that <code>etags</code> generates almost 1 GB. You mention that only some ".h" files available at build time, do you mean those files only generated after the build? Even if it is the case, it's hard to think that any tag program misses those if search recursively."},{"owner":{"reputation":11,"user_id":2265,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a2e453f8f1cfc1ff0d7428c3b66ddc9a?s=128&d=identicon&r=PG","display_name":"cheezy","link":"http://emacs.stackexchange.com/users/2265/cheezy"},"reply_to_user":{"reputation":652,"user_id":200,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/4468daf477f79462d675b0be10cd6e22?s=128&d=identicon&r=PG&f=1","display_name":"Tu Do","link":"http://emacs.stackexchange.com/users/200/tu-do"},"edited":false,"score":0,"post_type":"question","creation_date":1414790397,"post_id":2919,"comment_id":4009,"body_markdown":"Thanks! I saw your post on helm gtags and this'll work for me for now! Please create an answer so I can accept it :)","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable#comment4009_2919","body":"Thanks! I saw your post on helm gtags and this'll work for me for now! Please create an answer so I can accept it :)"}],"comment_count":10,"delete_vote_count":0,"reopen_vote_count":0,"close_vote_count":0,"is_answered":false,"view_count":19,"favorite_count":0,"answer_count":1,"score":2,"last_activity_date":1414793088,"creation_date":1414770468,"question_id":2919,"body_markdown":"**TLDR: I've got a large tags file that loads multiple times per session, making it unusable. Can't find the source of issue or how to disable it -- main goal is to jump to tags, but completion would be nice**\r\n\r\nI recently posted on the emacs subreddit and a user recommended that I join this group because it's also friendly towards newbies.\r\n\r\nI've been using emacs as a C++ IDE, and I'm slowly correcting things that are annoying. I'm essentially using [redguardtoo's emacs.d file][1].\r\n\r\nI have a tag file that is 225MB (1.6M Tags). My intent for the tag is not necessarily completion (using `company`), but more for jumping around source code. I'm working with an unfamiliar code base and often need to see macro or class definitions.\r\n\r\nWhen I start typing, at random times, I'll see a message in the minibuffer\r\n\r\n Making tag completion table for [tag file]...0-100%\r\n\r\nThen, a popup listbox shows up with autocompletion options.\r\n\r\nBecause this tag file is so large, and it doesn't seem like the tag loading is asynchronous, it freezes emacs for around a minute. This also happens multiple times per a session (with the same file, and with other files in the same directory that use the same tag file)!\r\n\r\n---\r\n\r\n**Questions**\r\n\r\n 1. Does anyone know what's initializing the loading of the tag table for completion and how to disable it? I did a grep on my emacs.d directory for "Making tag completion" and found nothing (note, IIRC the loading tags was present regardless of using `company` or `auto-complete`\r\n 2. Completion would be nice, but I'd settle just for the ability to jump to the tag location. Is there a way to get this? \r\n 3. What is the mindset to take when approaching problems like this? I'd like to be able to troubleshoot further on my own next time.\r\n\r\n [1]: https://github.com/redguardtoo/emacs.d\r\n\r\n---\r\n\r\n**Additional info**\r\n\r\nEnabled minor modes (C-h m)\r\n\r\n Enabled minor modes: Abbrev Auto-Composition Auto-Compression\r\n Auto-Encryption Blink-Cursor Column-Number Company Desktop-Save\r\n Display-Time Electric-Indent Electric-Pair Evil Evil-Local\r\n Evil-Matchit Evil-Surround Fic File-Name-Shadow Flyspell-Lazy\r\n Font-Lock Ggtags Global-Auto-Revert Global-Company Global-Eldoc\r\n Global-Evil-Matchit Global-Evil-Surround Global-Font-Lock Global-Linum\r\n Global-Page-Break-Lines Global-Pointback Global-Undo-Tree Helm\r\n Helm-Match-Plugin Helm-Occur-Match-Plugin Line-Number Linum Menu-Bar\r\n Mouse-Wheel Override-Global Pointback Recentf Savehist Shell-Dirtrack\r\n Subword Tooltip Undo-Tree Which-Function Window-Numbering Winner Yas\r\n Yas-Global\r\n\r\n","link":"http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable","title":""Making tag completion table" Freezes/Blocks -- how to disable","body":"<p><strong>TLDR: I've got a large tags file that loads multiple times per session, making it unusable. Can't find the source of issue or how to disable it -- main goal is to jump to tags, but completion would be nice</strong></p>\n\n<p>I recently posted on the emacs subreddit and a user recommended that I join this group because it's also friendly towards newbies.</p>\n\n<p>I've been using emacs as a C++ IDE, and I'm slowly correcting things that are annoying. I'm essentially using <a href=\"https://github.com/redguardtoo/emacs.d\" rel=\"nofollow\">redguardtoo's emacs.d file</a>.</p>\n\n<p>I have a tag file that is 225MB (1.6M Tags). My intent for the tag is not necessarily completion (using <code>company</code>), but more for jumping around source code. I'm working with an unfamiliar code base and often need to see macro or class definitions.</p>\n\n<p>When I start typing, at random times, I'll see a message in the minibuffer</p>\n\n<pre><code>Making tag completion table for [tag file]...0-100%\n</code></pre>\n\n<p>Then, a popup listbox shows up with autocompletion options.</p>\n\n<p>Because this tag file is so large, and it doesn't seem like the tag loading is asynchronous, it freezes emacs for around a minute. This also happens multiple times per a session (with the same file, and with other files in the same directory that use the same tag file)!</p>\n\n<hr>\n\n<p><strong>Questions</strong></p>\n\n<ol>\n<li>Does anyone know what's initializing the loading of the tag table for completion and how to disable it? I did a grep on my emacs.d directory for \"Making tag completion\" and found nothing (note, IIRC the loading tags was present regardless of using <code>company</code> or <code>auto-complete</code></li>\n<li>Completion would be nice, but I'd settle just for the ability to jump to the tag location. Is there a way to get this? </li>\n<li>What is the mindset to take when approaching problems like this? I'd like to be able to troubleshoot further on my own next time.</li>\n</ol>\n\n<hr>\n\n<p><strong>Additional info</strong></p>\n\n<p>Enabled minor modes (C-h m)</p>\n\n<pre><code>Enabled minor modes: Abbrev Auto-Composition Auto-Compression\nAuto-Encryption Blink-Cursor Column-Number Company Desktop-Save\nDisplay-Time Electric-Indent Electric-Pair Evil Evil-Local\nEvil-Matchit Evil-Surround Fic File-Name-Shadow Flyspell-Lazy\nFont-Lock Ggtags Global-Auto-Revert Global-Company Global-Eldoc\nGlobal-Evil-Matchit Global-Evil-Surround Global-Font-Lock Global-Linum\nGlobal-Page-Break-Lines Global-Pointback Global-Undo-Tree Helm\nHelm-Match-Plugin Helm-Occur-Match-Plugin Line-Number Linum Menu-Bar\nMouse-Wheel Override-Global Pointback Recentf Savehist Shell-Dirtrack\nSubword Tooltip Undo-Tree Which-Function Window-Numbering Winner Yas\nYas-Global\n</code></pre>\n"} |