<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Navigating the Neutral Zone]]></title><description><![CDATA[Stories from the neutral zone, right in between the corporate and the free software worlds. ]]></description><link>https://sebasmonia.github.io</link><generator>RSS for Node</generator><lastBuildDate>Fri, 03 Nov 2017 21:59:43 GMT</lastBuildDate><atom:link href="https://sebasmonia.github.io/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Using ediff with Visual Studio/Team Foundation Server]]></title><description><![CDATA[<div class="paragraph">
<p>There are plenty of posts about configuring alternative diff/merge tools to use with Team Foundation Server. The one I liked the most is <a href="http://blog.iannelson.systems/tfs-alternative-diff-merge-tools/" class="bare">http://blog.iannelson.systems/tfs-alternative-diff-merge-tools/</a> by Ian Nelson, who shows with nice screenshots HOW to change the TFS tools, and also includes a link to another post that explains the order in which the parameters are passed.</p>
</div>
<div class="paragraph">
<p>Putting together both posts I arrived at my current configuration to launch ediff when running compares from TFS:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://sebasmonia.github.io/images/TFSCompare.png" alt="Compare">
</div>
</div>
<div class="imageblock">
<div class="content">
<img src="https://sebasmonia.github.io/images/TFSMerge.png" alt="Merge">
</div>
</div>
<div class="paragraph">
<p>The little helper ediff.bat lives in my command line "binaries" folder (so it&#8217;s part of PATH) and its contents are pretty straigthforward:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>@echo off
set command=%1
set original=%2
set original=%original:\=\\%
set original=%original:"=\"%
set modified=%3
set modified=%modified:\=\\%
set modified=%modified:"=\"%

:compare
c:\HomeFolder\emacs\bin\emacsclientw -c -n -e "(ediff-files %original% %modified%)"
goto exit

:merge
set ancestor=%4
set ancestor=%ancestor:\=\\%
set ancestor=%ancestor:"=\"%
set output=%5
set output=%output:\=\\%
set output=%output:"=\"%
c:\HomeFolder\emacs\bin\emacsclientw -c -n -e "(ediff-merge-with-ancestor %original% %modified% %ancestor% nil %output%)"
goto exit

:exit</pre>
</div>
</div>
<div class="paragraph">
<p>Dissecting this, at first we have some string replace to escape the paths (\ becomes \\). As per the MSDN blog article, the paths are already quoted. Then through the -e parameter of emacsclientw we use elisp start ediff, for just a compare or merging. The list of entry points for ediff are in the Emacs manual.
You can also find a copy of the batch file in my Emacs configuration repository, but the above is all there is to it.</p>
</div>
<div class="paragraph">
<p>I figure an alternative would be an elisp funcion that you invoke and does the conversion of the strings to paths and then starts ediff. But since I already had some experience with batch files replaces, I just went with this approach.</p>
</div>
<div class="paragraph">
<p>Bonus! there are two configuration options that make this smoother:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>ediff-highlight-all-diffs: set to t to highlight the char-to-char differences instead of just blocks.</p>
</li>
<li>
<p>ediff-keep-variants: if you set this to nil, when quitting the ediff session you will be prompted to closed the buffers you just compared.</p>
</li>
</ul>
</div>]]></description><link>https://sebasmonia.github.io/2017/11/03/Using-ediff-with-Visual-Studio-Team-Foundation-Server.html</link><guid isPermaLink="true">https://sebasmonia.github.io/2017/11/03/Using-ediff-with-Visual-Studio-Team-Foundation-Server.html</guid><category><![CDATA[Emacs]]></category><category><![CDATA[VisualStudio]]></category><category><![CDATA[TFS]]></category><dc:creator><![CDATA[Sebastián Monía]]></dc:creator><pubDate>Fri, 03 Nov 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[Org-mode to HTML (yet another take)]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>One of the most useful pieces of configuration I did is also one of the most contrived.
So, before taking you on a tour of all the steps, here are the results:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://sebasmonia.github.io/images/OrgToHTMLClipboard.png" alt="It's worth it!">
</div>
</div>
<div class="paragraph">
<p>For us Windows corp users, Outlook, Excel, etc. are not going away. Easy ways to transition between worlds are always valuable.
The setup described below enables copying content from your org files to any other application by exporting the region as HTML and the putting that in the clipboard. From there, all Office applications are just one paste away!
I wish I could cite my sources on this more accurately, but honestly it&#8217;s been a while and the whole setup didn&#8217;t come to life in one go. It was rather a combination of pieces I found in a host of blogs and articles.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_step_1_pandoc_for_org_to_html">Step 1: Pandoc for org to HTML</h2>
<div class="sectionbody">
<div class="paragraph">
<p>You need the super useful <a href="http://pandoc.org/" class="bare">http://pandoc.org/</a> to convert your org files to HTML. I already had this installed as I tend to keep my documents in org-mode and export them to docx using Pandoc.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_step_2_utility_to_copy_html_to_clipboard">Step 2: Utility to copy HTML to clipboard</h2>
<div class="sectionbody">
<div class="paragraph">
<p>For this step I have a Python 3 version of this code: <a href="http://code.activestate.com/recipes/474121-getting-html-from-the-windows-clipboard/" class="bare">http://code.activestate.com/recipes/474121-getting-html-from-the-windows-clipboard/</a> with some more modifications so that it takes input from stdin.
You can find the modified code in my Emacs configuration repository: <a href="http://github.com/sebasmonia/emacs_cfg" class="bare">http://github.com/sebasmonia/emacs_cfg</a></p>
</div>
<div class="paragraph">
<p>This is the magical piece that I was missing for the longest time, since there are loads of tools for Linux and a few for OS X but almost nothing ready to use for Windows. The recipe linked above was a life saver! (and I found it looking for something entirely different)</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_step_3_elisp_glue">Step 3: Elisp glue</h2>
<div class="sectionbody">
<div class="paragraph">
<p>I "borrowed" a lot of this code too. It defines a new function that uses shell-command-on-region to pass the selected text to Pandoc, and then we pipe the resulting HTML as input for the script that sends everything to the clipboard. Finally we assign a binding for the new function.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-elisp" data-lang="elisp">(defun org-formatted-copy (&amp;optional b e)
  "Export region to HTML, and copy it to the clipboard."
  (interactive "r")
  (save-window-excursion
        (shell-command-on-region
         b
         e
         "pandoc -f org -t html | python c:/HomeFolder/PythonModules/htmlclip.py"))
  )
(global-set-key (kbd "C-M-w") 'org-formatted-copy)</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_step_4_profit">Step 4: Profit!</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Before having this contraption, sometimes for very long or content-heavy emails I used to open an org file and then export it via Pandoc. Now thanks to this quick binding, I can draft small tables, lists, etc. in my "scribble" file (seen in the screenshot) and then copy the resulting text very quickly to Outlook.
I can play with org-mode tables and then when I need a bigger tool, export it to Excel with a simple copy paste.
If any reader has found a way to make this more accesible <em>in Windows</em>, please let me know!</p>
</div>
</div>
</div>]]></description><link>https://sebasmonia.github.io/2017/10/27/Org-mode-to-HTML-yet-another-take.html</link><guid isPermaLink="true">https://sebasmonia.github.io/2017/10/27/Org-mode-to-HTML-yet-another-take.html</guid><category><![CDATA[Emacs]]></category><category><![CDATA[org]]></category><category><![CDATA[RubeGoldberg]]></category><category><![CDATA[Windows]]></category><category><![CDATA[Pandoc]]></category><dc:creator><![CDATA[Sebastián Monía]]></dc:creator><pubDate>Fri, 27 Oct 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[Find your %HOME%]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>I remember when I first started using Python at work (for personal use tools, nothing I could share with anyone <em>*cofcof*at least officially*cofcof*</em>) I quickly found out that I needed to configure some environment variables for things to work smoothly.
This felt, at a time, like a stylistic choice from the Python folks to get some configuration done in the simplest way possible while making it cross platform.</p>
</div>
<div class="paragraph">
<p>However, when I started using more and more tools that depended on environment variables, I realized that there&#8217;s a lot more than just %PATH% in life.
By the time I moved my home computer to Linux I was already more than comfortable with the idea that something depended on an environment variable.</p>
</div>
<div class="paragraph">
<p>So if you are taking the journey to master Python, Emacs, Vim, etc. and live in a Windows environment, I strongly suggest you select one folder in your hard drive and set it to %HOME%. For Emacs for example, this determines where your config files will live. By default Emacs will do the right thing and put it in your %USERPROFILE% (C:\Users\&lt;username&gt;, but in older versions of Windows it was "Documents and Settings").
In my case I used "C:\HomeFolder\" which honeslty sounds quite dumb. But you know, cache invalidation and naming things, right? (that&#8217;s one quote worth keeping in mind when starting a new project. And naming folders). It&#8217;s pretty short, quite unique (usually "Ho" &lt;TAB&gt; is enough to get it autocompleted) and no spaces. All good attributes.</p>
</div>
<div class="paragraph">
<p>That&#8217;s where I keep the config for all my tools. Python packages 99% of the time will drop the "dot directories" in there, Emacs as mentioned does the same. The reason for this is that in Linux/Unix, each user in the computer gets their own directory in /home/username, where all the "stuff" (not only config but documents, etc.) will live. In a way, it&#8217;s a combination of (some) registry settings and %USERPROFILE%.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="__home_is_where_the_bin_is">%HOME% is where the bin is</h2>
<div class="sectionbody">
<div class="paragraph">
<p>There&#8217;s one more thing I&#8217;ve added to my PATH that is semi-related to my home folder, which we usually don&#8217;t have in Windows but can come in quite handy, and that is a bin folder. Usually in Linux there&#8217;s a bin directory that contains the binaries (or, executables) for your tools. In Windows everything is spread out in the two Program Files folders, but if you start using more command line tools you&#8217;ll quickly realize it&#8217;s better to drop them all in one place.</p>
</div>
<div class="paragraph">
<p>So since these are things I call mostly from the command line I place my magic folder in C:\HomeFolder\cmdbin and for example that&#8217;s where I dropped the excellent GnuWin32/ezwinports utilities (Windows versions of grep, find, etc.). And then I added cmdbin to the PATH so from anywhere in the command line I can easily invoke the tools. By the way I also strongly advice against spaces in either of these directory names. It&#8217;s not that you can&#8217;t have spaces, but dealing with quoting paths all the time gets annoying fast.</p>
</div>
<div class="paragraph">
<p>Speaking of keeping things simple, the reason I didn&#8217;t just install Cygwin, is that I want to stay as much as possible in the "native" Windows world, so I can combine these tools with my older Win32 workflows more easily.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_dude_where_s_my_binaries_folder">Dude, where&#8217;s my binaries folder?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>One thing to notice, your user profile in many companies is setup in a way that you can login in different computers and have all your settings available.
I&#8217;ve never quite liked this feature, honestly. It depends (as many things in Windows do) on the app developers playing nicely and doing things The Right Way (which we rarely do&#8230;&#8203;). So if you rely on the profile, you&#8217;ll be dissappointed sooner or later, and on top of that your first login on a different computer can take a while to sync all your files.</p>
</div>
<div class="paragraph">
<p>With the Home folder approach, it&#8217;s definitely up to you to every once in a while to sync your folder between different computers or keep a backup in case your hard drive dies. That&#8217;s the reason I put my bin inside the home folder. Every once in a while (usually when I configured something new and it took me a while to get it working) I zip the entire thing and keep that copy somewhere else.
It happens rarely enough that it isn&#8217;t a huge pain, and at the same time if I have to move computers (which has already happened) getting my carefully created config up and running again it&#8217;s really straightforward.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_there_s_more">There&#8217;s more</h2>
<div class="sectionbody">
<div class="paragraph">
<p>I also recommended looking around the interwebs for PYTHONPATH, PYTHON, HTTP_PROXY and HTTPS_PROXY. These are as well documented as %HOME%, but unlike the later they are much less opinionated. The first two obviously apply to Python, but the proxy ones affect so many tools that I wonder if they shouldn&#8217;t be set by default&#8230;&#8203;</p>
</div>
</div>
</div>]]></description><link>https://sebasmonia.github.io/2017/10/23/Find-your-HOME.html</link><guid isPermaLink="true">https://sebasmonia.github.io/2017/10/23/Find-your-HOME.html</guid><category><![CDATA[MindTheGap]]></category><category><![CDATA[ConfigurationTips]]></category><dc:creator><![CDATA[Sebastián Monía]]></dc:creator><pubDate>Mon, 23 Oct 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[Three short Emacs tips for Windows]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>Three small tips for your <code>init.el</code> file.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_set_proxy">Set proxy</h2>
<div class="sectionbody">
<div class="paragraph">
<p>If you want to use MELPA, ELPA, etc. behind your corporate proxy, you need to configure it in the init file:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-elisp" data-lang="elisp">(setq url-proxy-services
   '(("no_proxy" . "^\\(localhost\\|10.*\\)")
     ("http" . "10.10.10.10:8080")
     ("https" . "10.10.10.10:8080")))</code></pre>
</div>
</div>
<div class="paragraph">
<p>A good way to get your proxy (unless the admins are cool and just share it) is to get the .dat file, as explained here: <a href="https://superuser.com/questions/346372/how-do-i-know-what-proxy-server-im-using" class="bare">https://superuser.com/questions/346372/how-do-i-know-what-proxy-server-im-using</a></p>
</div>
<div class="paragraph">
<p>I would also recommended to set the proxy in HTTP_PROXY and HTTPS_PROXY.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_utf_8">UTF-8</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Being a native Spanish speaker, sometimes I drop accented characters, like the á in Sebastián</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-elisp" data-lang="elisp">(prefer-coding-system 'utf-8)</code></pre>
</div>
</div>
<div class="paragraph">
<p>The problem seemed to be that the defauls in Emacs and in Windows are different&#8230;&#8203;or something like that. Whatever the case, this single line solved all my encoding problems.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_dired_launch">Dired-launch</h2>
<div class="sectionbody">
<div class="paragraph">
<p>I still deal daily with Excel, Word, Outlook, etc. I did replace 99% of  Windows Explorer with Dired, and one of the small tools that made a difference for me was dired-launch: <a href="https://github.com/thomp/dired-launch" class="bare">https://github.com/thomp/dired-launch</a>
Basically what dired-launch does is equivalent to <code>start "" file-path</code> in the command prompt.</p>
</div>
<div class="paragraph">
<p>I have it bound to J (shift + j) and C-c j, although I think J is the default binding, and for some reason I added an extra one that I&#8217;m not using?.
Anyway, for Windows there isn&#8217;t any other configuration required:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-elisp" data-lang="elisp">(dired-launch-enable)
(global-set-key (kbd "\C-cj") 'dired-jump)</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now you can launch any type of file from the Dired buffer directly.</p>
</div>
</div>
</div>]]></description><link>https://sebasmonia.github.io/2017/10/17/Three-short-Emacs-tips-for-Windows.html</link><guid isPermaLink="true">https://sebasmonia.github.io/2017/10/17/Three-short-Emacs-tips-for-Windows.html</guid><category><![CDATA[Emacs]]></category><category><![CDATA[MindTheGap]]></category><category><![CDATA[ShortTips]]></category><dc:creator><![CDATA[Sebastián Monía]]></dc:creator><pubDate>Tue, 17 Oct 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[Why this blog]]></title><description><![CDATA[<div class="paragraph">
<p>I&#8217;ve toyed with the idea of blogging quite a few times, as a lot of programmers do. So, why this time I&#8217;m really doing it? What gave me the push to get started?</p>
</div>
<div class="paragraph">
<p>It&#8217;s not like I didn&#8217;t have things to say, I always do, it&#8217;s just that now I feel I can say things that could be useful to others. After working for 10+ years purely in .NET and other related technologies, I&#8217;ve moved to more open things (Python, Linux).
But unlike many colleagues who made the jump from MS shops to Python/Ruby/etc. shops, I have NOT moved :) I still have my regular job with Exchange and corporate proxies and TFS-is-my-source-control-sad-smiley.</p>
</div>
<div class="paragraph">
<p>Another reason I think I can contribute to the conversation is that I don&#8217;t hate any of the tools that I&#8217;m leaving behind. A few days ago, I asked a question in r/emacs and someone gave me their condolences for using Visual Studio for so long. And I had to explain that even though I prefer other tools now, I can still appreciate how great of an IDE VS is. Heck if I&#8217;m in a hurry and I haven&#8217;t quite cracked how to get Emacs to play nicely with something I need, I won&#8217;t hesitate to start VS (and wait for a few minutes ;) at least for VS 2013/2015) to finish the job at hand.</p>
</div>
<div class="paragraph">
<p>So in essence, I feel my position is relatively unique/uncommon. I hope I can help others navigate The Neutral Zone, by documenting some of the things I do, how I workaround the differences between Linux and Windows, what worked for me and what didn&#8217;t.
And hopefully if someone ever reads this I can start getting their tips and together we can make our journey easier!</p>
</div>
<div class="paragraph">
<p>I&#8217;ll let the readers decide which group is the Federation and which group is the Romulans in my analogy. I&#8217;m not taking sides :)</p>
</div>
<div class="paragraph">
<p>PS: Since the blog is already up I might also share some more opinionated things, eventually. We&#8217;ll see.</p>
</div>]]></description><link>https://sebasmonia.github.io/2017/10/15/Why-this-blog.html</link><guid isPermaLink="true">https://sebasmonia.github.io/2017/10/15/Why-this-blog.html</guid><category><![CDATA[First_Post]]></category><category><![CDATA[Meta]]></category><category><![CDATA[Emacs]]></category><category><![CDATA[.NET]]></category><dc:creator><![CDATA[Sebastián Monía]]></dc:creator><pubDate>Sun, 15 Oct 2017 00:00:00 GMT</pubDate></item></channel></rss>