Skip to content

Commit

Permalink
[issue#206] Make clientserver optional
Browse files Browse the repository at this point in the history
  • Loading branch information
notalex committed Aug 8, 2016
1 parent a4e6757 commit cebcf23
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
12 changes: 6 additions & 6 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ To check for new messages in the current mailbox, press `u` in normal
mode if you're in the message list window or `,u` if you are in the
message window. Watch the status line.

If you have `notify-send` (Linux) or `growlnotify` (OS X) installed on
your system, Vmail can also poll your INBOX every 30 seconds for new
messages. If it detects a new message, it will alert you through your
notification program. **NOTE**: This is an alert mechanism only;
you will still have to manually check for new messages in the Vmail
interface to force the new messages to display.
If you have `notify-send` (Linux) or `growlnotify` (OS X) installed on your
system, Vmail can also poll your INBOX every 30 seconds for new messages. If it
detects a new message, it will alert you through your notification program.
**NOTE**: If vim is compiled with the `clientserver` flag, the new messages
will be displayed automatically. Else, one will have to manually check for
new messages(`u`) to get them displayed.

To enable automatic inbox polling put the line `polling: true` in your `.vmailrc`.

Expand Down
13 changes: 11 additions & 2 deletions lib/vmail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def config
@config ||= options.config
end

def has_clientserver?
@has_clientserver ||= system("#{ vim } --version | grep +clientserver")
end

def change_directory_to_vmail_home
working_dir = ENV['VMAIL_HOME'] || "#{ ENV['HOME'] }/.vmail/default"
`mkdir -p #{ working_dir }`
Expand Down Expand Up @@ -145,7 +149,6 @@ def start_imap_daemon
def start_vim(mailbox, query_string)
vimscript = File.expand_path("../vmail.vim", __FILE__)
vimopts = config['vim_opts']
server_name = "VMAIL:#{ config['username'] }"
contacts_file = options.contacts_file

vim_options = {
Expand All @@ -155,7 +158,7 @@ def start_vim(mailbox, query_string)
'VMAIL_QUERY' => %("#{ query_string }")
}

vim_command = "#{ vim } --servername #{ server_name } -S #{ vimscript } -c '#{ vimopts }' #{ BUFFER_FILE }"
vim_command = "#{ vim } #{ server_opts } -S #{ vimscript } -c '#{ vimopts }' #{ BUFFER_FILE }"

STDERR.puts vim_options
STDERR.puts vim_command
Expand Down Expand Up @@ -186,6 +189,12 @@ def close_connection
def vim
ENV['VMAIL_VIM'] || 'vim'
end

def server_opts
return unless has_clientserver?
server_name = "VMAIL:#{ config['username'] }"
"--servername #{ server_name }"
end
end

if __FILE__ == $0
Expand Down
2 changes: 1 addition & 1 deletion lib/vmail/imap_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def check_for_new_messages
self.max_seqno = ids.max
log "- setting max_seqno to #{ self.max_seqno }"
log "- new uids found: #{ new_ids.inspect }"
update_message_list(new_ids) unless new_ids.empty?
update_message_list(new_ids) if new_ids.any? && has_clientserver?
new_ids
end

Expand Down

0 comments on commit cebcf23

Please sign in to comment.