Macports is one of the most popular package manager system for MacOS. Usually, when you want to install Macports, you will download the automatic installer from Macports website. This is convenient for those people who first come to Macports’s world. Usually, the best way to backup with Mac is to backup your home directory. However, Macports by default will install all its packages into /opt/local, which make it difficult when you want to re-install your whole system or migrate to a new Mac because it’s outside your home directory.

The solution is to install Macports into your home directory and config it to put all its stuff into your home directory, too. By using this method, you can easily backup your home directory and start your work immediately with all your favorite applications/packages when you re-install the whole system.

There is one thing to notice. Not all packages from Macports can be installed and launched from your home directory. The ones that cannot are those that need to create another user, interact with folders outside your home dir,… (tasks that need sudo permission). One example that I have encountered is Mysql server. It needs to create another user to run the instance of Mysql but I think we can config it (I have not tried yet). To fix this, simply install 2 instances of Macports, one using the default installer and one in your home directory.

Read more

I’ve just implemented new feature for CEFM - Scrolling chat conversation.

Usually, while you are chatting with your friend, you want to scroll up the conversation for viewing the conversation history. The command facebook-scroll-up-current-coversation and facebook-scroll-down-current-coversation will help you easily scroll through the current chat conversation that you are in. Simply bind it to any key stroke that you want to use, for example

define_key(facebook_keymap, "C-I", "facebook-scroll-up-current-coversation");
define_key(facebook_keymap, "C-K", "facebook-scroll-down-current-coversation");

You can also config the scroll gap (the distance for each scroll) by setting the following variable

facebook_mode_scroll_gap = 50;

For more information about the mode, visit its homepage at http://truongtx.me/conkeror-extended-facebook-mode.html

Read more

Conkeror and Emacs are my two most used applications, one for web browsing and one for text editing, developing. It would be very great if I could use Emacs to interact directly with Conkeror for developing purpose. Fortunately, I found Mozrepl, an extension that “lets us program Firefox and other Mozilla-based applications from the inside” (quoted from Mozrepl homepage). This article is to summarize the steps on to set up Mozrepl in Conkeror and Emacs.

Install Mozrepl extension for Conkeror

You cannot directly install Mozrepl for Conkeror from Mozilla Add-ons page. Instead, you need to download it from the Mozilla Add-ons page, edit the install.rdf file and do a forced-installation following the instruction here Conkeror Extensions.

Config Mozrepl

Create a file named mozrepl-conkeror.js inside your home directory. Place this code as the file’s content

var conkeror = Cc["@conkeror.mozdev.org/application;1"]
	.getService().wrappedJSObject;

this.enter(conkeror);

Next, open your .conkerorrc and add this piece of code inside it to start the Mozrepl immediately when Conkeror start and then load the config file above.

Read more

Today, I have added my extension for Conkeror some new features. They are small but really useful for interacting with Facebook effectively through the keyboard.

You can find the information as well as the instruction on how to install and use at the package’s homepage http://truongtx.me/conkeror-extended-facebook-mode.html

Cycle through chat conversions with keyboard

Everything will be great if there is a handy keystroke for cycling through chat conversations. CEFM provides a useful command named facebook-cycle-conversations to help you solve this problem. Simply bind it to a keystroke that you want, for example

define_key(facebook_keymap, "C-C", "facebook-cycle-conversations");

Now in every facebook page, type q to search for a friend to chat, press C-C to jump to the next chat conversation. Usually if you press Esc, the current chat conversation will be closed. If you want to continue browsing Facebook without closing it, you can see the steps how to achieve it in this post Using Esc key in Conkeror.

Functions to fix fallthrough keys that Facebook cannot recognize

For keys from 0-9, there is a little problem so that I have to implement some custom functions for performing their functionalities but have not finished all, they will appear in the next version.

  • 3 - Open Friend Requests panel
  • 4 - Open Messages panel
  • 5 - Open Notifications panel
Read more

Another extension for Conkeror for browsing Facebook has been released today. This is just the very first version so it has only two features but they are really useful. It provides the ability to scroll through a long news feed page and open the story that you want to read later with ease. Have a look at it homepage, try it, bookmark this page and you’ll be notified when there is a new version release.

Conkeror Extended Facebook Mode: Homepage

In this very first version, I have only implemented 2 features. They are Fallthroughkeys and Open News Feed Story in new buffer

Read more

Copying folder path is a regular task that I use almost every day. It would be very useful if I can quickly copy the path that I’m currently working in Finder or Terminal and then switch to other application to continue working on that folder. Finder does not have any built-in feature for copying the current path using the keyboard. However, we can use a workaround with help from Apple Automator.

Finder

To copy the current path in Finder, open Automator and create a new Service. Config this service to receive no input in Finder application. After that, add Run AppleScript action to the work flow. Replace (* Your script goes here *) with this

try
    tell application "Finder" to set the clipboard to POSIX path of (target of window 1 as alias)
on error
    beep
end try

If you want it to copy as quoted, you can change POSIX path to quoted form of POSIX path.

Save the service with a name that you want. Remember that name so we can use it later to bind a shortcut key for it.

Read more

Today, I have finished my first package for Conkeror: Conkeror Mac Modeline Buttons. This is a really useful package for people who are new to Conkeror.

The source code is hosted on Github at https://github.com/tmtxt/conkeror-mac-modeline-buttons. The information as well as the instruction on how to install and use is presented on the homepage at Conkeror Mac Modeline Buttons.

This is the demo picture. Give it a try and comment me anything that I can improve

Demo

Read more

MacOS comes with a powerful search tool, Spotlight, that helps us find any file in our computer at a glance. It’s would be great if we can integrate it with Emacs and use it as a replacement for the default Emacs’ find-file command so that we can jump to any file we want to edit without remembering the location. Luckily, there is an useful program called mdfind, a command line interface for Spotlight. We will use it in combination with the locate (or helm-locate if you’re using helm) command.

1. Emacs built-in “locate” command

The step to use Spotlight with locate command is really simple. You just need to set the variable locate-command to mdfind to let Emacs use mdfind instead of locate for searching file.

(setq locate-command "mdfind")

When you want to use it, type in M-x locate and enter the keyword to search. The result will be displayed in a new buffer. Simply press Return on the file to open it for editing. If you follow the instruction in this post Dired as Default File Manager - More Advanced Tips on how to open file using MacOS default program, you can use that function/keystroke to open the file in search result with that default program.

This method is super fast since Spotlight has already indexed your Mac while you use it. Usually, it takes me just 1-2 seconds to display all the result and it’s can be faster on a Mac running an SSD.

Read more

Emacs is my favorite text editor and I use it as the main one for composing my blog. However, sometimes when I’m typing too fast and I’m lazy to proofread my article to some minor spelling error. Now I find a built-in solution in Emacs to help me automatically find any spelling errors in my article.

Emacs is shipped with flyspell-mode and ispell, which use a command line program for check the spelling. In most GNU/Linux distros, these programs are pre-installed in the OS so you don’t need to do anything in order to use flyspell-mode, just type M-x and flyspell-mode.

However, MacOS is not shipped with any spell checker program so you will receive the error Searching for program: No such file or directory when you try to activate flyspell-mode in Emacs. We need to configure a bit for Emacs on MacOS to run properly.

First, you need to install aspell, a spell checker program from macports. If you’re not familiar with macports, have a look at this post MacPorts - The MacOS package manager. Install aspell from macports using this command

Read more

Although I’m using emacs dired as my default file manager, I don’t like any of the terminal emulators in Emacs at all. I usually use a separate application for working with shell command (iTerm on Mac). The problem is that when I’m browsing my files in Emacs and I want to open terminal for doing shell commands in the current directory, I have to copy the path of the current directory, open terminal and type cd to that folder.

I’ve written a small function to help me quickly open a new terminal window at the current directory that I’m browsing in Emacs (MacOS only).

;; default terminal application path
(defvar tmtxt/macos-default-terminal-app-path
	"/Applications/Terminal.app" "The default path to terminal application in MacOS")
;;; function to open new terminal window at current directory
  (defun tmtxt/open-current-dir-in-terminal ()
	"Open current directory in dired mode in terminal application.
For MacOS only"
	(interactive)

	(shell-command (concat "open -a "
						   (shell-quote-argument tmtxt/macos-default-terminal-app-path)
						   " "
						   (shell-quote-argument (file-truename default-directory)))))
Read more